Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f9bc40a

Browse filesBrowse files
santigimenoRafaelGSS
authored andcommitted
test: use uv_sleep() where possible
PR-URL: #45124 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: theanarkh <theratliter@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de>
1 parent 243c141 commit f9bc40a
Copy full SHA for f9bc40a

File tree

Expand file treeCollapse file tree

2 files changed

+4
-28
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-28
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/addons/async-hello-world/binding.cc
+1-12Lines changed: 1 addition & 12 deletions
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

Collapse file

‎test/node-api/test_async/test_async.c‎

Copy file name to clipboardExpand all lines: test/node-api/test_async/test_async.c
+3-16Lines changed: 3 additions & 16 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.