Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatoli Papirovski <apapirovski@mac.com>2018-01-14 00:51:28 +0300
committerAnatoli Papirovski <apapirovski@mac.com>2018-01-18 23:55:59 +0300
commitc1234673bbba1ac6c8425dffb2604ccf647bbfcf (patch)
treea23f91d29eb1c1209e74c37b2aef8ef8a98b5e76 /src/timer_wrap.cc
parent7809f386b03d6f2f570fe41060a7ef6e158f5cdb (diff)
timers: allow Immediates to be unrefed
Refactor Immediates handling to allow for them to be unrefed, similar to setTimeout, but without extra handles. Document the new `immediate.ref()` and `immediate.unref()` methods. Add SetImmediateUnref on the C++ side. PR-URL: https://github.com/nodejs/node/pull/18139 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/timer_wrap.cc')
-rw-r--r--src/timer_wrap.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/timer_wrap.cc b/src/timer_wrap.cc
index ab450fcb3e7..1725cf30e71 100644
--- a/src/timer_wrap.cc
+++ b/src/timer_wrap.cc
@@ -83,16 +83,16 @@ class TimerWrap : public HandleWrap {
CHECK(args[0]->IsFunction());
auto env = Environment::GetCurrent(args);
env->set_immediate_callback_function(args[0].As<Function>());
- auto activate_cb = [] (const FunctionCallbackInfo<Value>& args) {
- Environment::GetCurrent(args)->ActivateImmediateCheck();
+ auto toggle_ref_cb = [] (const FunctionCallbackInfo<Value>& args) {
+ Environment::GetCurrent(args)->ToggleImmediateRef(args[0]->IsTrue());
};
- auto activate_function =
- env->NewFunctionTemplate(activate_cb)->GetFunction(env->context())
+ auto toggle_ref_function =
+ env->NewFunctionTemplate(toggle_ref_cb)->GetFunction(env->context())
.ToLocalChecked();
auto result = Array::New(env->isolate(), 2);
- result->Set(env->context(), 0, activate_function).FromJust();
- result->Set(env->context(), 1,
+ result->Set(env->context(), 0,
env->immediate_info()->fields().GetJSArray()).FromJust();
+ result->Set(env->context(), 1, toggle_ref_function).FromJust();
args.GetReturnValue().Set(result);
}