forked from adamlaska/electron
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmicrotasks_runner.h
More file actions
37 lines (28 loc) · 1.16 KB
/
microtasks_runner.h
File metadata and controls
37 lines (28 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (c) 2018 GitHub, Inc.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef ELECTRON_SHELL_BROWSER_MICROTASKS_RUNNER_H_
#define ELECTRON_SHELL_BROWSER_MICROTASKS_RUNNER_H_
#include "base/task/task_observer.h"
namespace v8 {
class Isolate;
}
namespace electron {
// Microtasks like promise resolution, are run at the end of the current
// task. This class implements a task observer that runs tells v8 to run them.
// Microtasks runner implementation is based on the EndOfTaskRunner in blink.
// Node follows the kExplicit MicrotasksPolicy, and we do the same in browser
// process. Hence, we need to have this task observer to flush the queued
// microtasks.
class MicrotasksRunner : public base::TaskObserver {
public:
explicit MicrotasksRunner(v8::Isolate* isolate);
// base::TaskObserver
void WillProcessTask(const base::PendingTask& pending_task,
bool was_blocked_or_low_priority) override;
void DidProcessTask(const base::PendingTask& pending_task) override;
private:
v8::Isolate* isolate_;
};
} // namespace electron
#endif // ELECTRON_SHELL_BROWSER_MICROTASKS_RUNNER_H_