From 8c73eee23f15ef11b6ef3b8f8113f78a95794e47 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 22 Nov 2019 15:30:56 -0500 Subject: unix,win: add uv_sleep() This commit exposes the uv_sleep() function that previously only existed in the test runner. PR-URL: https://github.com/libuv/libuv/pull/2548 Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau --- src/unix/core.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/unix/core.c') diff --git a/src/unix/core.c b/src/unix/core.c index ffce948c..2d5479af 100644 --- a/src/unix/core.c +++ b/src/unix/core.c @@ -1555,3 +1555,15 @@ int uv_gettimeofday(uv_timeval64_t* tv) { tv->tv_usec = (int32_t) time.tv_usec; return 0; } + +void uv_sleep(unsigned int msec) { + unsigned int sec; + unsigned int usec; + + sec = msec / 1000; + usec = (msec % 1000) * 1000; + if (sec > 0) + sleep(sec); + if (usec > 0) + usleep(usec); +} -- cgit v1.2.3