mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
test: use uv_sleep() where possible
PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
1 parent
68a3ce5246
commit
09cbb66f04
2 files changed
+4
-28
No files matched your search
@@ -2,13 +2,6 @@
|
||||
#include <v8.h>
|
||||
#include <uv.h>
|
||||
|
||||
#if defined _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
struct async_req {
|
||||
uv_work_t req;
|
||||
int input;
|
||||
@@ -21,11 +14,7 @@ struct async_req {
|
||||
void DoAsync(uv_work_t* r) {
|
||||
async_req* req = reinterpret_cast<async_req*>(r->data);
|
||||
// Simulate CPU intensive process...
|
||||
#if defined _WIN32
|
||||
Sleep(1000);
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
uv_sleep(1000);
|
||||
req->output = req->input * 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <node_api.h>
|
||||
#include <uv.h>
|
||||
#include "../../js-native-api/common.h"
|
||||
|
||||
#if defined _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
// this needs to be greater than the thread pool size
|
||||
#define MAX_CANCEL_THREADS 6
|
||||
|
||||
@@ -23,11 +18,7 @@ static carrier the_carrier;
|
||||
static carrier async_carrier[MAX_CANCEL_THREADS];
|
||||
|
||||
static void Execute(napi_env env, void* data) {
|
||||
#if defined _WIN32
|
||||
Sleep(1000);
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
uv_sleep(1000);
|
||||
carrier* c = (carrier*)(data);
|
||||
|
||||
assert(c == &the_carrier);
|
||||
@@ -130,11 +121,7 @@ static void CancelComplete(napi_env env, napi_status status, void* data) {
|
||||
}
|
||||
|
||||
static void CancelExecute(napi_env env, void* data) {
|
||||
#if defined _WIN32
|
||||
Sleep(1000);
|
||||
#else
|
||||
sleep(1);
|
||||
#endif
|
||||
uv_sleep(1000);
|
||||
}
|
||||
|
||||
static napi_value TestCancel(napi_env env, napi_callback_info info) {
|
||||
|
||||
Reference in new issue
Block a user