add support to sleep for shorter periods of time;

4.01b_maint
Bryan Biedenkapp 2 years ago
parent 7ec138ed13
commit e66365f3f4

@ -84,9 +84,13 @@ void Thread::detach()
/* Helper to sleep the current thread. */ /* Helper to sleep the current thread. */
void Thread::sleep(uint32_t ms) void Thread::sleep(uint32_t ms, uint32_t us)
{ {
::usleep(ms * 1000); if (us > 0U) {
::usleep(us);
} else {
::usleep(ms * 1000U);
}
} }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------

@ -77,8 +77,9 @@ public:
/** /**
* @brief Helper to sleep the current thread. * @brief Helper to sleep the current thread.
* @param ms Time in milliseconds to sleep. * @param ms Time in milliseconds to sleep.
* @param us Time in microseconds to sleep.
*/ */
static void sleep(uint32_t ms); static void sleep(uint32_t ms, uint32_t us = 0U);
private: private:
pthread_t m_thread; pthread_t m_thread;

Loading…
Cancel
Save

Powered by TurnKey Linux.