diff --git a/qse/include/qse/si/App.hpp b/qse/include/qse/si/App.hpp index c6ffc14d..2552d770 100644 --- a/qse/include/qse/si/App.hpp +++ b/qse/include/qse/si/App.hpp @@ -59,6 +59,7 @@ public: void sleep (const qse_ntime_t* duration) QSE_CPP_NOEXCEPT; void sleep (unsigned int seconds) QSE_CPP_NOEXCEPT; + void msleep (qse_mtime_t duration) QSE_CPP_NOEXCEPT; #if 0 int switchUser (qse_uid_t uid, qse_gid_t gid, bool permanently) QSE_CPP_NOEXCEPT; diff --git a/qse/include/qse/si/Thread.hpp b/qse/include/qse/si/Thread.hpp index ecb49f53..8ed39876 100644 --- a/qse/include/qse/si/Thread.hpp +++ b/qse/include/qse/si/Thread.hpp @@ -99,6 +99,11 @@ public: static qse_ntime_t duration = { seconds, 0 }; qse_sleep (&duration); } + + void msleep (qse_mtime_t duration) QSE_CPP_NOEXCEPT + { + qse_msleep (duration); + } protected: qse_thr_t thr; diff --git a/qse/include/qse/si/os.h b/qse/include/qse/si/os.h index 91aefe7a..e0f734e3 100644 --- a/qse/include/qse/si/os.h +++ b/qse/include/qse/si/os.h @@ -42,6 +42,10 @@ QSE_EXPORT void qse_sleep ( const qse_ntime_t* interval ); +QSE_EXPORT void qse_msleep ( + const qse_mtime_t interval +); + #if defined(__cplusplus) } #endif diff --git a/qse/lib/si/App.cpp b/qse/lib/si/App.cpp index 26d13d6b..cb60295b 100644 --- a/qse/lib/si/App.cpp +++ b/qse/lib/si/App.cpp @@ -207,6 +207,11 @@ void App::sleep (unsigned int seconds) QSE_CPP_NOEXCEPT qse_sleep (&duration); } +void App::msleep (const qse_mtime_t duration) QSE_CPP_NOEXCEPT +{ + qse_msleep (duration); +} + #if 0 int App::switchPrivilege (int gid, int uid, bool permanently) { diff --git a/qse/lib/si/os.c b/qse/lib/si/os.c index 3568c7d1..54e04c2c 100644 --- a/qse/lib/si/os.c +++ b/qse/lib/si/os.c @@ -56,6 +56,23 @@ void qse_sleep (const qse_ntime_t* interval) #endif } +void qse_msleep (qse_mtime_t interval) +{ +#if defined(_WIN32) + Sleep (interval); +#elif defined(__OS2__) + DosSleep (interval); +#elif defined(HAVE_NANOSLEEP) + struct timespec ts; + ts.tv_sec = QSE_MSEC_TO_SEC(interval); + interval -= QSE_SEC_TO_MSEC(ts.tv_sec); + ts.tv_nsec = QSE_MSEC_TO_NSEC(interval); + nanosleep (&ts, &ts); +#else + sleep (QSE_MSEC_TO_SEC(interval)); +#endif +} + /* TODO: int qse_set_proc_name (const qse_char_t* name)