summaryrefslogtreecommitdiff
path: root/src/node_util.cc
diff options
context:
space:
mode:
authorcjihrig <cjihrig@gmail.com>2019-12-03 23:02:49 -0500
committercjihrig <cjihrig@gmail.com>2019-12-06 22:02:47 -0500
commitf446929923d6cfa471721404d9d7f806449d5fe6 (patch)
tree53f2e904fa5736ea050729f51320dc35c2faeebc /src/node_util.cc
parent4ec02d5afdad4610b59fbc22ff2279e35120294e (diff)
downloadandroid-node-v8-f446929923d6cfa471721404d9d7f806449d5fe6.tar.gz
android-node-v8-f446929923d6cfa471721404d9d7f806449d5fe6.tar.bz2
android-node-v8-f446929923d6cfa471721404d9d7f806449d5fe6.zip
util: add internal sleep() function
PR-URL: https://github.com/nodejs/node/pull/30787 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Diffstat (limited to 'src/node_util.cc')
-rw-r--r--src/node_util.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/node_util.cc b/src/node_util.cc
index 07a7b69dbd..b9553eaaa6 100644
--- a/src/node_util.cc
+++ b/src/node_util.cc
@@ -169,6 +169,12 @@ static void SetHiddenValue(const FunctionCallbackInfo<Value>& args) {
args.GetReturnValue().Set(maybe_value.FromJust());
}
+static void Sleep(const FunctionCallbackInfo<Value>& args) {
+ CHECK(args[0]->IsUint32());
+ uint32_t msec = args[0].As<Uint32>()->Value();
+ uv_sleep(msec);
+}
+
void ArrayBufferViewHasBuffer(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsArrayBufferView());
args.GetReturnValue().Set(args[0].As<ArrayBufferView>()->HasBuffer());
@@ -290,6 +296,7 @@ void Initialize(Local<Object> target,
env->SetMethodNoSideEffect(target, "getOwnNonIndexProperties",
GetOwnNonIndexProperties);
env->SetMethodNoSideEffect(target, "getConstructorName", GetConstructorName);
+ env->SetMethod(target, "sleep", Sleep);
env->SetMethod(target, "arrayBufferViewHasBuffer", ArrayBufferViewHasBuffer);
Local<Object> constants = Object::New(env->isolate());