Skip to content

Instantly share code, notes, and snippets.

@deepal
Created October 15, 2019 21:37
Show Gist options
  • Select an option

  • Save deepal/2a5ac3537ab5443d888f0a9af4736e4b to your computer and use it in GitHub Desktop.

Select an option

Save deepal/2a5ac3537ab5443d888f0a9af4736e4b to your computer and use it in GitHub Desktop.
Ref() or Unref() a worker thread
void Worker::Ref(const FunctionCallbackInfo<Value>& args) {
Worker* w;
ASSIGN_OR_RETURN_UNWRAP(&w, args.This());
uv_ref(reinterpret_cast<uv_handle_t*>(w->on_thread_finished_.GetHandle()));
}
void Worker::Unref(const FunctionCallbackInfo<Value>& args) {
Worker* w;
ASSIGN_OR_RETURN_UNWRAP(&w, args.This());
uv_unref(reinterpret_cast<uv_handle_t*>(w->on_thread_finished_.GetHandle()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment