added qse_msleep()

This commit is contained in:
hyung-hwan 2019-03-12 08:42:05 +00:00
parent d41f8e75e0
commit e61b34b17b
5 changed files with 32 additions and 0 deletions

View File

@ -59,6 +59,7 @@ public:
void sleep (const qse_ntime_t* duration) QSE_CPP_NOEXCEPT; void sleep (const qse_ntime_t* duration) QSE_CPP_NOEXCEPT;
void sleep (unsigned int seconds) QSE_CPP_NOEXCEPT; void sleep (unsigned int seconds) QSE_CPP_NOEXCEPT;
void msleep (qse_mtime_t duration) QSE_CPP_NOEXCEPT;
#if 0 #if 0
int switchUser (qse_uid_t uid, qse_gid_t gid, bool permanently) QSE_CPP_NOEXCEPT; int switchUser (qse_uid_t uid, qse_gid_t gid, bool permanently) QSE_CPP_NOEXCEPT;

View File

@ -99,6 +99,11 @@ public:
static qse_ntime_t duration = { seconds, 0 }; static qse_ntime_t duration = { seconds, 0 };
qse_sleep (&duration); qse_sleep (&duration);
} }
void msleep (qse_mtime_t duration) QSE_CPP_NOEXCEPT
{
qse_msleep (duration);
}
protected: protected:
qse_thr_t thr; qse_thr_t thr;

View File

@ -42,6 +42,10 @@ QSE_EXPORT void qse_sleep (
const qse_ntime_t* interval const qse_ntime_t* interval
); );
QSE_EXPORT void qse_msleep (
const qse_mtime_t interval
);
#if defined(__cplusplus) #if defined(__cplusplus)
} }
#endif #endif

View File

@ -207,6 +207,11 @@ void App::sleep (unsigned int seconds) QSE_CPP_NOEXCEPT
qse_sleep (&duration); qse_sleep (&duration);
} }
void App::msleep (const qse_mtime_t duration) QSE_CPP_NOEXCEPT
{
qse_msleep (duration);
}
#if 0 #if 0
int App::switchPrivilege (int gid, int uid, bool permanently) int App::switchPrivilege (int gid, int uid, bool permanently)
{ {

View File

@ -56,6 +56,23 @@ void qse_sleep (const qse_ntime_t* interval)
#endif #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: TODO:
int qse_set_proc_name (const qse_char_t* name) int qse_set_proc_name (const qse_char_t* name)