diff options
author | Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com> | 2014-09-22 20:19:50 +0400 |
---|---|---|
committer | Trevor Norris <trev.norris@gmail.com> | 2014-10-01 14:42:05 -0700 |
commit | 8dc6be1747d3a48af56f89e973ecb5665f89a2e1 (patch) | |
tree | 2f97df1b5b14c3dee8bb20bb74eb7dde00865ae4 /src/async-wrap-inl.h | |
parent | b705b73e46193c7691be40b732330a49affacedb (diff) | |
download | node-new-8dc6be1747d3a48af56f89e973ecb5665f89a2e1.tar.gz |
node: avoid automatic microtask runs
Since we are taking control of the microtask queue it makes sense to
disable autorun and only run microtasks when necessary. Just setting
isolate->SetAutorunMicrotasks(false) would cause _tickCallback() not to
be called.
Automatically running the microtask queue will cause it to run:
* After callback invocation
* Inside _tickCallback()
* After _tickCallback() invocation
The third one is unnecessary as the microtask queue is guaranteed to be
empty at this point. The first only needs to be run manually when
_tickCallback() isn't going to be called by MakeCallback().
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'src/async-wrap-inl.h')
-rw-r--r-- | src/async-wrap-inl.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/async-wrap-inl.h b/src/async-wrap-inl.h index 324c57b9ae..59157cc0f4 100644 --- a/src/async-wrap-inl.h +++ b/src/async-wrap-inl.h @@ -139,6 +139,10 @@ inline v8::Handle<v8::Value> AsyncWrap::MakeDomainCallback( } if (tick_info->length() == 0) { + env()->isolate()->RunMicrotasks(); + } + + if (tick_info->length() == 0) { tick_info->set_index(0); return ret; } @@ -202,6 +206,10 @@ inline v8::Handle<v8::Value> AsyncWrap::MakeCallback( } if (tick_info->length() == 0) { + env()->isolate()->RunMicrotasks(); + } + + if (tick_info->length() == 0) { tick_info->set_index(0); return ret; } |