added wxMilli/MicroSleep(), deprecated wxUsleep()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28140 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2004-07-01 22:54:48 +00:00
parent 4e0f1c33cc
commit 66cd9d7f55

View File

@@ -149,12 +149,12 @@ void wxSleep(int nSecs)
sleep(nSecs); sleep(nSecs);
} }
void wxUsleep(unsigned long milliseconds) void wxMicroSleep(unsigned long microseconds)
{ {
#if defined(HAVE_NANOSLEEP) #if defined(HAVE_NANOSLEEP)
timespec tmReq; timespec tmReq;
tmReq.tv_sec = (time_t)(milliseconds / 1000); tmReq.tv_sec = (time_t)(microseconds / 1000000);
tmReq.tv_nsec = (milliseconds % 1000) * 1000 * 1000; tmReq.tv_nsec = (microseconds % 1000000) * 1000;
// we're not interested in remaining time nor in return value // we're not interested in remaining time nor in return value
(void)nanosleep(&tmReq, (timespec *)NULL); (void)nanosleep(&tmReq, (timespec *)NULL);
@@ -167,15 +167,20 @@ void wxUsleep(unsigned long milliseconds)
#error "usleep() cannot be used in MT programs under Solaris." #error "usleep() cannot be used in MT programs under Solaris."
#endif // Sun #endif // Sun
usleep(milliseconds * 1000); // usleep(3) wants microseconds usleep(microseconds);
#elif defined(HAVE_SLEEP) #elif defined(HAVE_SLEEP)
// under BeOS sleep() takes seconds (what about other platforms, if any?) // under BeOS sleep() takes seconds (what about other platforms, if any?)
sleep(milliseconds * 1000); sleep(microseconds * 1000000);
#else // !sleep function #else // !sleep function
#error "usleep() or nanosleep() function required for wxUsleep" #error "usleep() or nanosleep() function required for wxMicroSleep"
#endif // sleep function #endif // sleep function
} }
void wxMilliSleep(unsigned long milliseconds)
{
wxMicroSleep(milliseconds*1000);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// process management // process management
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------