From 08873d362be3e09d83b2da7b062f5c5f4e4f3711 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 1 Jul 2004 12:15:00 +0000 Subject: [PATCH] added wxMilli/MicroSleep(), deprecated wxUsleep() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28135 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + docs/latex/wx/function.tex | 40 +++++++++++++++++++++++++++++++------- include/wx/utils.h | 8 +++++++- src/common/utilscmn.cpp | 5 +++++ src/msw/utils.cpp | 9 +++++++-- 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 583bb24b1e..d77a41d0cd 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -117,6 +117,7 @@ All: - fixed bug in wxDateTime::Set(jdn) when DST was in effect - support msgids in charsets other than C and languages other than English (based on patch by Stefan Kowski) +- added wxMicroSleep() and wxMilliSleep() replacing deprecated wxUsleep() All (GUI): diff --git a/docs/latex/wx/function.tex b/docs/latex/wx/function.tex index 07004569b9..8a74f3974e 100644 --- a/docs/latex/wx/function.tex +++ b/docs/latex/wx/function.tex @@ -174,6 +174,8 @@ the corresponding topic. \helpref{wxMakeMetafilePlaceable}{wxmakemetafileplaceable}\\ \helpref{wxMatchWild}{wxmatchwild}\\ \helpref{wxMessageBox}{wxmessagebox}\\ +\helpref{wxMilliSleep}{wxmillisleep}\\ +\helpref{wxMicroSleep}{wxmicrosleep}\\ \helpref{wxMkdir}{wxmkdir}\\ \helpref{wxMutexGuiEnter}{wxmutexguienter}\\ \helpref{wxMutexGuiLeave}{wxmutexguileave}\\ @@ -3843,6 +3845,33 @@ Returns the number of seconds since GMT 00:00:00 Jan 1st 1970. +\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} + + + + +\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} + + + + \membersection{::wxNow}\label{wxnow} \func{wxString}{wxNow}{\void} @@ -3882,13 +3911,10 @@ See also \helpref{wxTimer}{wxtimer}. \func{void}{wxUsleep}{\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} - - +This function is deprecated because its name is misleading: notice that the +argument is in milliseconds, not microseconds. Please use either +\helpref{wxMilliSleep}{wxmillisleep} or \helpref{wxMicroSleep}{wxmicrosleep} +depending on the resolution you need. diff --git a/include/wx/utils.h b/include/wx/utils.h index 439325d635..88ad888f3d 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -257,7 +257,13 @@ WXDLLIMPEXP_BASE bool wxShell(const wxString& command, wxArrayString& output); WXDLLIMPEXP_BASE void wxSleep(int nSecs); // 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 WXDLLIMPEXP_BASE unsigned long wxGetProcessId(); diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 2fd1c86901..205d577d42 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -266,6 +266,11 @@ wxString wxNow() #endif } +void wxUsleep(unsigned long milliseconds) +{ + wxMilliSleep(milliseconds); +} + const wxChar *wxGetInstallPrefix() { wxString prefix; diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index 3f96945518..696fdc5fa8 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -1030,14 +1030,19 @@ wxToolkitInfo& wxAppTraits::GetToolkitInfo() // sleep functions // ---------------------------------------------------------------------------- -void wxUsleep(unsigned long milliseconds) +void wxMilliSleep(unsigned long milliseconds) { ::Sleep(milliseconds); } +void wxMicroSleep(unsigned long microseconds) +{ + wxMilliSleep(microseconds/1000); +} + void wxSleep(int nSecs) { - wxUsleep(1000*nSecs); + wxMilliSleep(1000*nSecs); } // ---------------------------------------------------------------------------- -- 2.45.2