GeezerVison is showing github.com — test: use uv_sleep() where possible · nodejs/node@7b8380d
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: test/addons/async-hello-world/binding.cc +1-12Lines changed: 1 addition & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
2 | 2 | #include <v8.h> |
3 | 3 | #include <uv.h> |
4 | 4 |
|
5 | | -#if defined _WIN32 |
6 | | -#include <windows.h> |
7 | | -#else |
8 | | -#include <unistd.h> |
9 | | -#endif |
10 | | - |
11 | | - |
12 | 5 | struct async_req { |
13 | 6 | uv_work_t req; |
14 | 7 | int input; |
@@ -21,11 +14,7 @@ struct async_req { |
21 | 14 | void DoAsync(uv_work_t* r) { |
22 | 15 | async_req* req = reinterpret_cast<async_req*>(r->data); |
23 | 16 | // Simulate CPU intensive process... |
24 | | -#if defined _WIN32 |
25 | | - Sleep(1000); |
26 | | -#else |
27 | | - sleep(1); |
28 | | -#endif |
| 17 | + uv_sleep(1000); |
29 | 18 | req->output = req->input * 2; |
30 | 19 | } |
31 | 20 |
|
|
Collapse file
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 number | Diff line number | Diff line change |
|---|
|
1 | 1 | #include <assert.h> |
2 | 2 | #include <stdio.h> |
3 | 3 | #include <node_api.h> |
| 4 | +#include <uv.h> |
4 | 5 | #include "../../js-native-api/common.h" |
5 | 6 |
|
6 | | -#if defined _WIN32 |
7 | | -#include <windows.h> |
8 | | -#else |
9 | | -#include <unistd.h> |
10 | | -#endif |
11 | | - |
12 | 7 | // this needs to be greater than the thread pool size |
13 | 8 | #define MAX_CANCEL_THREADS 6 |
14 | 9 |
|
@@ -23,11 +18,7 @@ static carrier the_carrier; |
23 | 18 | static carrier async_carrier[MAX_CANCEL_THREADS]; |
24 | 19 |
|
25 | 20 | 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); |
31 | 22 | carrier* c = (carrier*)(data); |
32 | 23 |
|
33 | 24 | assert(c == &the_carrier); |
@@ -130,11 +121,7 @@ static void CancelComplete(napi_env env, napi_status status, void* data) { |
130 | 121 | } |
131 | 122 |
|
132 | 123 | 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); |
138 | 125 | } |
139 | 126 |
|
140 | 127 | static napi_value TestCancel(napi_env env, napi_callback_info info) { |
|