It's mac only.
// The MessageLoop should have been created, remember the one in main thread.
message_loop_ = base::MessageLoop::current();
- // Get notified when libuv's watcher queue changes.
- uv_loop_->data = this;
- uv_loop_->on_watcher_queue_updated = OnWatcherQueueChanged;
-
// Run uv loop for once to give the uv__io_poll a chance to add all events.
UvRunOnce();
}
base::Unretained(this)));
}
+void NodeBindings::WakeupEmbedThread() {
+ uv_async_send(&dummy_uv_handle_);
+}
+
// static
void NodeBindings::EmbedThreadRunner(void *arg) {
NodeBindings* self = static_cast<NodeBindings*>(arg);
}
}
-// static
-void NodeBindings::OnWatcherQueueChanged(uv_loop_t* loop) {
- NodeBindings* self = static_cast<NodeBindings*>(loop->data);
-
- DCHECK(!self->is_browser_ || BrowserThread::CurrentlyOn(BrowserThread::UI));
-
- // We need to break the io polling in the kqueue thread when loop's watcher
- // queue changes, otherwise new events cannot be notified.
- uv_async_send(&self->dummy_uv_handle_);
-}
-
} // namespace atom
// Make the main thread run libuv loop.
void WakeupMainThread();
+ // Interrupt the PollEvents.
+ void WakeupEmbedThread();
+
// Are we running in browser.
bool is_browser_;
// Thread to poll uv events.
static void EmbedThreadRunner(void *arg);
- // Called when uv's watcher queue changes.
- static void OnWatcherQueueChanged(uv_loop_t* loop);
-
// Whether the libuv loop has ended.
bool embed_closed_;
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_);
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.