Improve the way to integrate libuv.
Now we poll libuv's events in embed thread by adding main loop's backend fd to a new kqueue fd, instead of directly polling on main loop's backend fd. In this way we can avoid dealing with one shot events overselves.
This commit is contained in:
parent
603ae8b62e
commit
855b42551d
2 changed files with 18 additions and 79 deletions
|
@ -5,10 +5,6 @@
|
|||
#ifndef ATOM_COMMON_NODE_BINDINGS_MAC_
|
||||
#define ATOM_COMMON_NODE_BINDINGS_MAC_
|
||||
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "base/compiler_specific.h"
|
||||
#include "common/node_bindings.h"
|
||||
#include "vendor/node/deps/uv/include/uv.h"
|
||||
|
@ -27,12 +23,6 @@ class NodeBindingsMac : public NodeBindings {
|
|||
// Run the libuv loop for once.
|
||||
void UvRunOnce();
|
||||
|
||||
// Run pending one shot events if we have.
|
||||
void DealWithPendingEvent();
|
||||
|
||||
// Called when kqueue notifies new event.
|
||||
void OnKqueueHasNewEvents();
|
||||
|
||||
// Thread to poll uv events.
|
||||
static void EmbedThreadRunner(void *arg);
|
||||
|
||||
|
@ -42,6 +32,9 @@ class NodeBindingsMac : public NodeBindings {
|
|||
// Main thread's loop.
|
||||
uv_loop_t* loop_;
|
||||
|
||||
// Kqueue to poll for uv's backend fd.
|
||||
int kqueue_;
|
||||
|
||||
// Dummy handle to make uv's loop not quit.
|
||||
uv_async_t dummy_uv_handle_;
|
||||
|
||||
|
@ -54,10 +47,6 @@ class NodeBindingsMac : public NodeBindings {
|
|||
// Semaphore to wait for main loop in the embed thread.
|
||||
uv_sem_t embed_sem_;
|
||||
|
||||
// Captured oneshot event in embed thread.
|
||||
bool has_pending_event_;
|
||||
struct ::kevent event_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NodeBindingsMac);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue