From: Cheng Zhao Date: Sat, 18 Jan 2014 08:56:46 +0000 (+0800) Subject: Activate uv loop when uv loop's watcher queue changes, fixes #159. X-Git-Tag: v0.9.5~1^2~23 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=4a1f8cf1c9e5267d557e784d8954a51f47d4dadd;p=electron.git Activate uv loop when uv loop's watcher queue changes, fixes #159. --- diff --git a/common/node_bindings_mac.cc b/common/node_bindings_mac.cc index 3397e35a..0a31a1dd 100644 --- a/common/node_bindings_mac.cc +++ b/common/node_bindings_mac.cc @@ -26,6 +26,23 @@ NodeBindingsMac::NodeBindingsMac(bool is_browser) NodeBindingsMac::~NodeBindingsMac() { } +void NodeBindingsMac::RunMessageLoop() { + // Get notified when libuv's watcher queue changes. + uv_loop_->data = this; + uv_loop_->on_watcher_queue_updated = OnWatcherQueueChanged; + + NodeBindings::RunMessageLoop(); +} + +// static +void NodeBindingsMac::OnWatcherQueueChanged(uv_loop_t* loop) { + NodeBindingsMac* self = static_cast(loop->data); + + // We need to break the io polling in the kqueue thread when loop's watcher + // queue changes, otherwise new events cannot be notified. + self->WakeupEmbedThread(); +} + void NodeBindingsMac::PollEvents() { struct timespec spec; int timeout = uv_backend_timeout(uv_loop_); diff --git a/common/node_bindings_mac.h b/common/node_bindings_mac.h index 6ae79c0a..4929c1a2 100644 --- a/common/node_bindings_mac.h +++ b/common/node_bindings_mac.h @@ -15,7 +15,12 @@ class NodeBindingsMac : public NodeBindings { explicit NodeBindingsMac(bool is_browser); virtual ~NodeBindingsMac(); + virtual void RunMessageLoop() OVERRIDE; + private: + // Called when uv's watcher queue changes. + static void OnWatcherQueueChanged(uv_loop_t* loop); + virtual void PollEvents() OVERRIDE; // Kqueue to poll for uv's backend fd. diff --git a/vendor/node b/vendor/node index 184a341c..7fa64485 160000 --- a/vendor/node +++ b/vendor/node @@ -1 +1 @@ -Subproject commit 184a341c2b959a092f64b168e3d55b11d13583bf +Subproject commit 7fa644854f91c8dd23d8cec21be1310f0b69d813