Create new uv loop in each worker

This commit is contained in:
Cheng Zhao 2017-03-10 15:22:25 +09:00
parent 69df934710
commit d2f185bea5
2 changed files with 3 additions and 3 deletions

View file

@ -98,7 +98,7 @@ base::FilePath GetResourcesPath(bool is_browser) {
NodeBindings::NodeBindings(BrowserEnvironment browser_env)
: browser_env_(browser_env),
uv_loop_(uv_default_loop()),
uv_loop_(browser_env == WORKER ? uv_loop_new() : uv_default_loop()),
embed_closed_(false),
uv_env_(nullptr),
weak_factory_(this) {
@ -169,7 +169,7 @@ node::Environment* NodeBindings::CreateEnvironment(
std::unique_ptr<const char*[]> c_argv = StringVectorToArgArray(args);
node::Environment* env = node::CreateEnvironment(
new node::IsolateData(context->GetIsolate(), uv_default_loop()), context,
new node::IsolateData(context->GetIsolate(), uv_loop_), context,
args.size(), c_argv.get(), 0, nullptr);
if (browser_env_ == BROWSER) {

View file

@ -40,7 +40,7 @@ WebWorkerObserver::~WebWorkerObserver() {
void WebWorkerObserver::ContextCreated(v8::Local<v8::Context> context) {
v8::Context::Scope context_scope(context);
node_bindings_->Initialize();
// Start the embed thread.
node_bindings_->PrepareMessageLoop();
// Setup node environment for each window.