|
@@ -29,6 +29,29 @@ NodeBindingsWin::NodeBindingsWin(BrowserEnvironment browser_env)
|
|
|
|
|
|
NodeBindingsWin::~NodeBindingsWin() = default;
|
|
|
|
|
|
+void NodeBindingsWin::PrepareMessageLoop() {
|
|
|
+ // IOCP does not change for the process until the loop is recreated,
|
|
|
+ // we ensure that there is only a single polling thread satisfying
|
|
|
+ // the concurrency limit set from CreateIoCompletionPort call by
|
|
|
+ // uv_loop_init for the lifetime of this process.
|
|
|
+ if (initialized_)
|
|
|
+ return;
|
|
|
+
|
|
|
+ NodeBindings::PrepareMessageLoop();
|
|
|
+}
|
|
|
+
|
|
|
+void NodeBindingsWin::RunMessageLoop() {
|
|
|
+ // Avoid calling UvRunOnce if the loop is already active,
|
|
|
+ // otherwise it can lead to situations were the number of active
|
|
|
+ // threads processing on IOCP is greater than the concurrency limit.
|
|
|
+ if (initialized_)
|
|
|
+ return;
|
|
|
+
|
|
|
+ initialized_ = true;
|
|
|
+
|
|
|
+ NodeBindings::RunMessageLoop();
|
|
|
+}
|
|
|
+
|
|
|
void NodeBindingsWin::PollEvents() {
|
|
|
// If there are other kinds of events pending, uv_backend_timeout will
|
|
|
// instruct us not to wait.
|