mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
* refactor: make ElectronRendererClient::node_bindings_ a const ptr refactor: make ElectronRendererClient::electron_bindings_ a const ptr Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: make NodeBindings::in_worker_loop() private Co-authored-by: Charles Kerr <charles@charleskerr.com> * fix: raw_ptr destructor dependency in NodeBindings Co-authored-by: Charles Kerr <charles@charleskerr.com> * chore: revert unintentional commit Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: make NodeBindings::uv_loop_ private Co-authored-by: Charles Kerr <charles@charleskerr.com> * refactor: extract event_loop init into a separate function for readability Co-authored-by: Charles Kerr <charles@charleskerr.com> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Charles Kerr <charles@charleskerr.com>
49 lines
1.1 KiB
C++
49 lines
1.1 KiB
C++
// Copyright (c) 2013 GitHub, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "shell/common/node_bindings_mac.h"
|
|
|
|
#include <errno.h>
|
|
#include <sys/select.h>
|
|
#include <sys/sysctl.h>
|
|
#include <sys/time.h>
|
|
#include <sys/types.h>
|
|
|
|
#include "shell/common/node_includes.h"
|
|
|
|
namespace electron {
|
|
|
|
NodeBindingsMac::NodeBindingsMac(BrowserEnvironment browser_env)
|
|
: NodeBindings(browser_env) {}
|
|
|
|
void NodeBindingsMac::PollEvents() {
|
|
auto* const event_loop = uv_loop();
|
|
|
|
struct timeval tv;
|
|
int timeout = uv_backend_timeout(event_loop);
|
|
if (timeout != -1) {
|
|
tv.tv_sec = timeout / 1000;
|
|
tv.tv_usec = (timeout % 1000) * 1000;
|
|
}
|
|
|
|
fd_set readset;
|
|
int fd = uv_backend_fd(event_loop);
|
|
FD_ZERO(&readset);
|
|
FD_SET(fd, &readset);
|
|
|
|
// Wait for new libuv events.
|
|
int r;
|
|
do {
|
|
r = select(fd + 1, &readset, nullptr, nullptr,
|
|
timeout == -1 ? nullptr : &tv);
|
|
} while (r == -1 && errno == EINTR);
|
|
}
|
|
|
|
// static
|
|
NodeBindings* NodeBindings::Create(BrowserEnvironment browser_env) {
|
|
return new NodeBindingsMac(browser_env);
|
|
}
|
|
|
|
} // namespace electron
|