Skip to content

Commit f9bc40a

Browse files
santigimenoRafaelGSS
authored andcommitted
test: use uv_sleep() where possible
PR-URL: #45124 Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: theanarkh <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Daeyeon Jeong <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Gerhard Stöbich <[email protected]>
1 parent 243c141 commit f9bc40a

File tree

2 files changed

+4
-28
lines changed

2 files changed

+4
-28
lines changed

test/addons/async-hello-world/binding.cc

+1-12
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22
#include <v8.h>
33
#include <uv.h>
44

5-
#if defined _WIN32
6-
#include <windows.h>
7-
#else
8-
#include <unistd.h>
9-
#endif
10-
11-
125
struct async_req {
136
uv_work_t req;
147
int input;
@@ -21,11 +14,7 @@ struct async_req {
2114
void DoAsync(uv_work_t* r) {
2215
async_req* req = reinterpret_cast<async_req*>(r->data);
2316
// Simulate CPU intensive process...
24-
#if defined _WIN32
25-
Sleep(1000);
26-
#else
27-
sleep(1);
28-
#endif
17+
uv_sleep(1000);
2918
req->output = req->input * 2;
3019
}
3120

test/node-api/test_async/test_async.c

+3-16
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
#include <assert.h>
22
#include <stdio.h>
33
#include <node_api.h>
4+
#include <uv.h>
45
#include "../../js-native-api/common.h"
56

6-
#if defined _WIN32
7-
#include <windows.h>
8-
#else
9-
#include <unistd.h>
10-
#endif
11-
127
// this needs to be greater than the thread pool size
138
#define MAX_CANCEL_THREADS 6
149

@@ -23,11 +18,7 @@ static carrier the_carrier;
2318
static carrier async_carrier[MAX_CANCEL_THREADS];
2419

2520
static void Execute(napi_env env, void* data) {
26-
#if defined _WIN32
27-
Sleep(1000);
28-
#else
29-
sleep(1);
30-
#endif
21+
uv_sleep(1000);
3122
carrier* c = (carrier*)(data);
3223

3324
assert(c == &the_carrier);
@@ -130,11 +121,7 @@ static void CancelComplete(napi_env env, napi_status status, void* data) {
130121
}
131122

132123
static void CancelExecute(napi_env env, void* data) {
133-
#if defined _WIN32
134-
Sleep(1000);
135-
#else
136-
sleep(1);
137-
#endif
124+
uv_sleep(1000);
138125
}
139126

140127
static napi_value TestCancel(napi_env env, napi_callback_info info) {

0 commit comments

Comments
 (0)