diff options
author | cjihrig <cjihrig@gmail.com> | 2019-11-22 15:30:56 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2019-11-25 12:13:39 -0500 |
commit | 8c73eee23f15ef11b6ef3b8f8113f78a95794e47 (patch) | |
tree | 225d5ee07b6dcca4ebbf2665d5276e999bbea903 /src/unix/core.c | |
parent | 96cfa783a24e154fd3d3124e159aec277537f494 (diff) | |
download | libuv-8c73eee23f15ef11b6ef3b8f8113f78a95794e47.tar.gz libuv-8c73eee23f15ef11b6ef3b8f8113f78a95794e47.zip |
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 <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'src/unix/core.c')
-rw-r--r-- | src/unix/core.c | 12 |
1 files changed, 12 insertions, 0 deletions
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); +} |