SHARE
TWEET

Untitled

a guest Jun 27th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. void AsyncWrap::EmitAsyncInit(Environment* env,
  2.                               Local<Object> object,
  3.                               Local<String> type,
  4.                               double async_id,
  5.                               double trigger_async_id) {
  6.   CHECK(!object.IsEmpty());
  7.   CHECK(!type.IsEmpty());
  8.   AsyncHooks* async_hooks = env->async_hooks();
  9.  
  10.   // Nothing to execute, so can continue normally.
  11.   if (async_hooks->fields()[AsyncHooks::kInit] == 0) {
  12.     return;
  13.   }
  14.  
  15.   HandleScope scope(env->isolate());
  16.   Local<Function> init_fn = env->async_hooks_init_function();
  17.  
  18.   Local<Value> argv[] = {
  19.     Number::New(env->isolate(), async_id),
  20.     type,
  21.     Number::New(env->isolate(), trigger_async_id),
  22.     object,
  23.   };
  24.  
  25.   TryCatchScope try_catch(env, TryCatchScope::CatchMode::kFatal);
  26.   USE(init_fn->Call(env->context(), object, arraysize(argv), argv));
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top