added App::sleep()

This commit is contained in:
hyung-hwan 2018-09-17 02:51:52 +00:00
parent 3a66a8d927
commit 016e7da24a
3 changed files with 18 additions and 1 deletions

View File

@ -129,7 +129,7 @@ struct qse_btime_t
static QSE_INLINE void qse_cleartime(qse_ntime_t* x) { qse_inittime (x, 0, 0); } static QSE_INLINE void qse_cleartime(qse_ntime_t* x) { qse_inittime (x, 0, 0); }
/*static QSE_INLINE int qse_cmptime(qse_ntime_t* x, qse_ntime_t* y) /*static QSE_INLINE int qse_cmptime(qse_ntime_t* x, qse_ntime_t* y)
{ {
/* TODO: fix the type and value range issue and replace the macro below. // TODO: fix the type and value range issue and replace the macro below.
return (x->sec == y->sec)? (x->nsec - y->nsec): (x->sec - y->sec); return (x->sec == y->sec)? (x->nsec - y->nsec): (x->sec - y->sec);
}*/ }*/
# define qse_cmptime(x,y) (((x)->sec == (y)->sec)? ((x)->nsec - (y)->nsec): ((x)->sec - (y)->sec)) # define qse_cmptime(x,y) (((x)->sec == (y)->sec)? ((x)->nsec - (y)->nsec): ((x)->sec - (y)->sec))

View File

@ -31,6 +31,7 @@
#include <qse/Uncopyable.hpp> #include <qse/Uncopyable.hpp>
#include <qse/cmn/Mmged.hpp> #include <qse/cmn/Mmged.hpp>
#include <qse/cmn/Bitset.hpp> #include <qse/cmn/Bitset.hpp>
#include <qse/cmn/time.h>
///////////////////////////////// /////////////////////////////////
QSE_BEGIN_NAMESPACE(QSE) QSE_BEGIN_NAMESPACE(QSE)
@ -56,6 +57,9 @@ public:
int chroot (const qse_mchar_t* mpath) QSE_CPP_NOEXCEPT; int chroot (const qse_mchar_t* mpath) QSE_CPP_NOEXCEPT;
int chroot (const qse_wchar_t* wpath) QSE_CPP_NOEXCEPT; int chroot (const qse_wchar_t* wpath) QSE_CPP_NOEXCEPT;
void sleep (const qse_ntime_t* duration) QSE_CPP_NOEXCEPT;
void sleep (unsigned int seconds) 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;
int restoreUser () QSE_CPP_NOEXCEPT; int restoreUser () QSE_CPP_NOEXCEPT;

View File

@ -27,9 +27,11 @@
#include <qse/si/App.hpp> #include <qse/si/App.hpp>
#include <qse/si/Mutex.hpp> #include <qse/si/Mutex.hpp>
#include <qse/si/sinfo.h> #include <qse/si/sinfo.h>
#include <qse/si/os.h>
#include "../cmn/syscall.h" #include "../cmn/syscall.h"
#include <qse/cmn/mbwc.h> #include <qse/cmn/mbwc.h>
///////////////////////////////// /////////////////////////////////
QSE_BEGIN_NAMESPACE(QSE) QSE_BEGIN_NAMESPACE(QSE)
///////////////////////////////// /////////////////////////////////
@ -190,6 +192,17 @@ int App::chroot (const qse_wchar_t* wpath) QSE_CPP_NOEXCEPT
return n; return n;
} }
void App::sleep (const qse_ntime_t* duration) QSE_CPP_NOEXCEPT
{
qse_sleep (duration);
}
void App::sleep (unsigned int seconds) QSE_CPP_NOEXCEPT
{
static qse_ntime_t duration = { seconds, 0 };
qse_sleep (&duration);
}
#if 0 #if 0
int App::switchPrivilege (int gid, int uid, bool permanently) int App::switchPrivilege (int gid, int uid, bool permanently)
{ {