2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2014-02-14 14:39:57 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2019-06-19 20:46:59 +00:00
|
|
|
#include "shell/common/node_bindings_linux.h"
|
2014-02-14 14:39:57 +00:00
|
|
|
|
2014-02-21 05:21:02 +00:00
|
|
|
#include <sys/epoll.h>
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
namespace electron {
|
2014-02-14 14:39:57 +00:00
|
|
|
|
2017-03-08 08:33:44 +00:00
|
|
|
NodeBindingsLinux::NodeBindingsLinux(BrowserEnvironment browser_env)
|
2018-04-18 01:55:30 +00:00
|
|
|
: NodeBindings(browser_env), epoll_(epoll_create(1)) {
|
2014-02-21 05:21:02 +00:00
|
|
|
int backend_fd = uv_backend_fd(uv_loop_);
|
2018-04-18 01:55:30 +00:00
|
|
|
struct epoll_event ev = {0};
|
2014-02-21 05:21:02 +00:00
|
|
|
ev.events = EPOLLIN;
|
|
|
|
ev.data.fd = backend_fd;
|
|
|
|
epoll_ctl(epoll_, EPOLL_CTL_ADD, backend_fd, &ev);
|
2014-02-14 14:39:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void NodeBindingsLinux::PollEvents() {
|
2014-02-21 05:21:02 +00:00
|
|
|
int timeout = uv_backend_timeout(uv_loop_);
|
|
|
|
|
|
|
|
// Wait for new libuv events.
|
|
|
|
int r;
|
|
|
|
do {
|
|
|
|
struct epoll_event ev;
|
|
|
|
r = epoll_wait(epoll_, &ev, 1, timeout);
|
|
|
|
} while (r == -1 && errno == EINTR);
|
2014-02-14 14:39:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
2017-03-08 08:33:44 +00:00
|
|
|
NodeBindings* NodeBindings::Create(BrowserEnvironment browser_env) {
|
|
|
|
return new NodeBindingsLinux(browser_env);
|
2014-02-14 14:39:57 +00:00
|
|
|
}
|
|
|
|
|
2019-06-19 21:23:04 +00:00
|
|
|
} // namespace electron
|