]> khamidou — GitHub mirrors - electron.git/commitdiff
Activate uv loop when uv loop's watcher queue changes, fixes #159.
authorCheng Zhao <zcbenz@gmail.com>
Sat, 18 Jan 2014 08:56:46 +0000 (16:56 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 18 Jan 2014 08:56:46 +0000 (16:56 +0800)
common/node_bindings_mac.cc
common/node_bindings_mac.h
vendor/node

index 3397e35a5ed557434ca1ed44ba686b5b03651ecb..0a31a1dd1fac4a55361fc7a5fa57627d9ac2de57 100644 (file)
@@ -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<NodeBindingsMac*>(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_);
index 6ae79c0a60b574228efd9de32ee02184083a418c..4929c1a2cf6d1bc2747aa07df0468e23031713a5 100644 (file)
@@ -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.
index 184a341c2b959a092f64b168e3d55b11d13583bf..7fa644854f91c8dd23d8cec21be1310f0b69d813 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 184a341c2b959a092f64b168e3d55b11d13583bf
+Subproject commit 7fa644854f91c8dd23d8cec21be1310f0b69d813