GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

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
Filter options
  • test
    • addons/async-hello-world
      • binding.cc
    • node-api/test_async
      • test_async.c
Expand file treeCollapse file tree
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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.