added wxMilli/MicroSleep(), deprecated wxUsleep()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28135 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2004-07-01 12:15:00 +00:00
parent f52d9e924c
commit 08873d362b
5 changed files with 53 additions and 10 deletions

View File

@@ -117,6 +117,7 @@ All:
- fixed bug in wxDateTime::Set(jdn) when DST was in effect - fixed bug in wxDateTime::Set(jdn) when DST was in effect
- support msgids in charsets other than C and languages other than English - support msgids in charsets other than C and languages other than English
(based on patch by Stefan Kowski) (based on patch by Stefan Kowski)
- added wxMicroSleep() and wxMilliSleep() replacing deprecated wxUsleep()
All (GUI): All (GUI):

View File

@@ -174,6 +174,8 @@ the corresponding topic.
\helpref{wxMakeMetafilePlaceable}{wxmakemetafileplaceable}\\ \helpref{wxMakeMetafilePlaceable}{wxmakemetafileplaceable}\\
\helpref{wxMatchWild}{wxmatchwild}\\ \helpref{wxMatchWild}{wxmatchwild}\\
\helpref{wxMessageBox}{wxmessagebox}\\ \helpref{wxMessageBox}{wxmessagebox}\\
\helpref{wxMilliSleep}{wxmillisleep}\\
\helpref{wxMicroSleep}{wxmicrosleep}\\
\helpref{wxMkdir}{wxmkdir}\\ \helpref{wxMkdir}{wxmkdir}\\
\helpref{wxMutexGuiEnter}{wxmutexguienter}\\ \helpref{wxMutexGuiEnter}{wxmutexguienter}\\
\helpref{wxMutexGuiLeave}{wxmutexguileave}\\ \helpref{wxMutexGuiLeave}{wxmutexguileave}\\
@@ -3843,6 +3845,33 @@ Returns the number of seconds since GMT 00:00:00 Jan 1st 1970.
<wx/timer.h> <wx/timer.h>
\membersection{::wxMicroSleep}\label{wxmicrosleep}
\func{void}{wxMicroSleep}{\param{unsigned long}{ microseconds}}
Sleeps for the specified number of microseconds. The microsecond resolution may
not, in fact, be available on all platforms (currently only Unix platforms with
nanosleep(2) may provide it) in which case this is the same as
\helpref{wxMilliSleep}{wxmillisleep}(\arg{microseconds}$/1000$).
\wxheading{Include files}
<wx/utils.h>
\membersection{::wxMilliSleep}\label{wxmillisleep}
\func{void}{wxMilliSleep}{\param{unsigned long}{ milliseconds}}
Sleeps for the specified number of milliseconds. Notice that usage of this
function is encouraged instead of calling usleep(3) directly because the
standard usleep() function is not MT safe.
\wxheading{Include files}
<wx/utils.h>
\membersection{::wxNow}\label{wxnow} \membersection{::wxNow}\label{wxnow}
\func{wxString}{wxNow}{\void} \func{wxString}{wxNow}{\void}
@@ -3882,13 +3911,10 @@ See also \helpref{wxTimer}{wxtimer}.
\func{void}{wxUsleep}{\param{unsigned long}{ milliseconds}} \func{void}{wxUsleep}{\param{unsigned long}{ milliseconds}}
Sleeps for the specified number of milliseconds. Notice that usage of this This function is deprecated because its name is misleading: notice that the
function is encouraged instead of calling usleep(3) directly because the argument is in milliseconds, not microseconds. Please use either
standard usleep() function is not MT safe. \helpref{wxMilliSleep}{wxmillisleep} or \helpref{wxMicroSleep}{wxmicrosleep}
depending on the resolution you need.
\wxheading{Include files}
<wx/utils.h>

View File

@@ -257,7 +257,13 @@ WXDLLIMPEXP_BASE bool wxShell(const wxString& command, wxArrayString& output);
WXDLLIMPEXP_BASE void wxSleep(int nSecs); WXDLLIMPEXP_BASE void wxSleep(int nSecs);
// Sleep for a given amount of milliseconds // Sleep for a given amount of milliseconds
WXDLLIMPEXP_BASE void wxUsleep(unsigned long milliseconds); WXDLLIMPEXP_BASE void wxMilliSleep(unsigned long milliseconds);
// Sleep for a given amount of microseconds
WXDLLIMPEXP_BASE void wxMicroSleep(unsigned long microseconds);
// Sleep for a given amount of milliseconds (old, bad name), use wxMilliSleep
wxDEPRECATED( WXDLLIMPEXP_BASE void wxUsleep(unsigned long milliseconds) );
// Get the process id of the current process // Get the process id of the current process
WXDLLIMPEXP_BASE unsigned long wxGetProcessId(); WXDLLIMPEXP_BASE unsigned long wxGetProcessId();

View File

@@ -266,6 +266,11 @@ wxString wxNow()
#endif #endif
} }
void wxUsleep(unsigned long milliseconds)
{
wxMilliSleep(milliseconds);
}
const wxChar *wxGetInstallPrefix() const wxChar *wxGetInstallPrefix()
{ {
wxString prefix; wxString prefix;

View File

@@ -1030,14 +1030,19 @@ wxToolkitInfo& wxAppTraits::GetToolkitInfo()
// sleep functions // sleep functions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxUsleep(unsigned long milliseconds) void wxMilliSleep(unsigned long milliseconds)
{ {
::Sleep(milliseconds); ::Sleep(milliseconds);
} }
void wxMicroSleep(unsigned long microseconds)
{
wxMilliSleep(microseconds/1000);
}
void wxSleep(int nSecs) void wxSleep(int nSecs)
{ {
wxUsleep(1000*nSecs); wxMilliSleep(1000*nSecs);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------