Run microtasks each iteration

This commit is contained in:
Alex Hultman 2019-02-08 21:20:57 +01:00
parent 493585e954
commit 80f10df8de
1 changed files with 4 additions and 0 deletions

View File

@ -54,6 +54,10 @@ void print(const FunctionCallbackInfo<Value> &args) {
* Should return int queueSize after calling queued items, so that * Should return int queueSize after calling queued items, so that
* proper while(processNextTickQueueImpl()) can be done */ * proper while(processNextTickQueueImpl()) can be done */
int processNextTickQueueImpl(Isolate *isolate) { int processNextTickQueueImpl(Isolate *isolate) {
/* Run async continuations, promises and other V8-queued tasks */
isolate->RunMicrotasks();
if (nextTickQueue.size()) { if (nextTickQueue.size()) {
/* Swap queues for recursive calls */ /* Swap queues for recursive calls */
std::vector<UniquePersistent<Function>> currentNextTickQueue = std::move(nextTickQueue); std::vector<UniquePersistent<Function>> currentNextTickQueue = std::move(nextTickQueue);