chore: remove redundant code in node integration (#33500)

This commit is contained in:
Cheng Zhao 2022-03-30 12:09:42 +09:00 committed by GitHub
parent df3cfb663c
commit c119b1ebef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 32 additions and 108 deletions

View file

@ -584,7 +584,16 @@ void NodeBindings::LoadEnvironment(node::Environment* env) {
gin_helper::EmitEvent(env->isolate(), env->process_object(), "loaded");
}
void NodeBindings::PrepareMessageLoop() {
void NodeBindings::PrepareEmbedThread() {
// 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.
// More background can be found at:
// https://github.com/microsoft/vscode/issues/142786#issuecomment-1061673400
if (initialized_)
return;
// Add dummy handle for libuv, otherwise libuv would quit when there is
// nothing to do.
uv_async_init(uv_loop_, dummy_uv_handle_.get(), nullptr);
@ -594,7 +603,15 @@ void NodeBindings::PrepareMessageLoop() {
uv_thread_create(&embed_thread_, EmbedThreadRunner, this);
}
void NodeBindings::RunMessageLoop() {
void NodeBindings::StartPolling() {
// 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;
// The MessageLoop should have been created, remember the one in main thread.
task_runner_ = base::ThreadTaskRunnerHandle::Get();