aboutsummaryrefslogtreecommitdiff
path: root/src/thread_posix.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread_posix.c')
-rw-r--r--src/thread_posix.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/thread_posix.c b/src/thread_posix.c
index 84e8e09..1122baf 100644
--- a/src/thread_posix.c
+++ b/src/thread_posix.c
@@ -55,6 +55,19 @@ bh_thread_t *bh_thread_new(bh_task_t *task)
return result;
}
+int bh_thread_sleep(unsigned long timeout)
+{
+ struct timespec ts;
+
+ ts.tv_sec = timeout / 1000;
+ ts.tv_nsec = (timeout - ts.tv_sec * 1000) * 1000000;
+
+ if (nanosleep(&ts, NULL))
+ return BH_ERROR;
+
+ return BH_OK;
+}
+
int bh_thread_join(bh_thread_t *thread)
{
/* Join the thread */