AtomBindings should not use default uv loop
This commit is contained in:
parent
9c9c8ec5f1
commit
c068285ff8
7 changed files with 14 additions and 10 deletions
|
@ -61,7 +61,7 @@ AtomBrowserMainParts::AtomBrowserMainParts()
|
||||||
exit_code_(nullptr),
|
exit_code_(nullptr),
|
||||||
browser_(new Browser),
|
browser_(new Browser),
|
||||||
node_bindings_(NodeBindings::Create(NodeBindings::BROWSER)),
|
node_bindings_(NodeBindings::Create(NodeBindings::BROWSER)),
|
||||||
atom_bindings_(new AtomBindings),
|
atom_bindings_(new AtomBindings(uv_default_loop())),
|
||||||
gc_timer_(true, true) {
|
gc_timer_(true, true) {
|
||||||
DCHECK(!self_) << "Cannot have two AtomBrowserMainParts";
|
DCHECK(!self_) << "Cannot have two AtomBrowserMainParts";
|
||||||
self_ = this;
|
self_ = this;
|
||||||
|
|
|
@ -78,8 +78,8 @@ void FatalErrorCallback(const char* location, const char* message) {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
AtomBindings::AtomBindings() {
|
AtomBindings::AtomBindings(uv_loop_t* loop) {
|
||||||
uv_async_init(uv_default_loop(), &call_next_tick_async_, OnCallNextTick);
|
uv_async_init(loop, &call_next_tick_async_, OnCallNextTick);
|
||||||
call_next_tick_async_.data = this;
|
call_next_tick_async_.data = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace atom {
|
||||||
|
|
||||||
class AtomBindings {
|
class AtomBindings {
|
||||||
public:
|
public:
|
||||||
AtomBindings();
|
explicit AtomBindings(uv_loop_t* loop);
|
||||||
virtual ~AtomBindings();
|
virtual ~AtomBindings();
|
||||||
|
|
||||||
// Add process.atomBinding function, which behaves like process.binding but
|
// Add process.atomBinding function, which behaves like process.binding but
|
||||||
|
|
|
@ -116,6 +116,10 @@ NodeBindings::~NodeBindings() {
|
||||||
// Clear uv.
|
// Clear uv.
|
||||||
uv_sem_destroy(&embed_sem_);
|
uv_sem_destroy(&embed_sem_);
|
||||||
uv_close(reinterpret_cast<uv_handle_t*>(&dummy_uv_handle_), nullptr);
|
uv_close(reinterpret_cast<uv_handle_t*>(&dummy_uv_handle_), nullptr);
|
||||||
|
|
||||||
|
// Destroy loop.
|
||||||
|
if (uv_loop_ != uv_default_loop())
|
||||||
|
uv_loop_delete(uv_loop_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeBindings::Initialize() {
|
void NodeBindings::Initialize() {
|
||||||
|
|
|
@ -52,6 +52,8 @@ class NodeBindings {
|
||||||
void set_uv_env(node::Environment* env) { uv_env_ = env; }
|
void set_uv_env(node::Environment* env) { uv_env_ = env; }
|
||||||
node::Environment* uv_env() const { return uv_env_; }
|
node::Environment* uv_env() const { return uv_env_; }
|
||||||
|
|
||||||
|
uv_loop_t* uv_loop() const { return uv_loop_; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit NodeBindings(BrowserEnvironment browser_env);
|
explicit NodeBindings(BrowserEnvironment browser_env);
|
||||||
|
|
||||||
|
@ -70,10 +72,10 @@ class NodeBindings {
|
||||||
// Which environment we are running.
|
// Which environment we are running.
|
||||||
BrowserEnvironment browser_env_;
|
BrowserEnvironment browser_env_;
|
||||||
|
|
||||||
// Main thread's MessageLoop.
|
// Current thread's MessageLoop.
|
||||||
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
|
||||||
|
|
||||||
// Main thread's libuv loop.
|
// Current thread's libuv loop.
|
||||||
uv_loop_t* uv_loop_;
|
uv_loop_t* uv_loop_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -217,7 +217,7 @@ std::vector<std::string> ParseSchemesCLISwitch(const char* switch_name) {
|
||||||
AtomRendererClient::AtomRendererClient()
|
AtomRendererClient::AtomRendererClient()
|
||||||
: node_integration_initialized_(false),
|
: node_integration_initialized_(false),
|
||||||
node_bindings_(NodeBindings::Create(NodeBindings::RENDERER)),
|
node_bindings_(NodeBindings::Create(NodeBindings::RENDERER)),
|
||||||
atom_bindings_(new AtomBindings) {
|
atom_bindings_(new AtomBindings(uv_default_loop())) {
|
||||||
isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
|
isolated_world_ = base::CommandLine::ForCurrentProcess()->HasSwitch(
|
||||||
switches::kContextIsolation);
|
switches::kContextIsolation);
|
||||||
// Parse --standard-schemes=scheme1,scheme2
|
// Parse --standard-schemes=scheme1,scheme2
|
||||||
|
|
|
@ -29,7 +29,7 @@ WebWorkerObserver* WebWorkerObserver::GetCurrent() {
|
||||||
|
|
||||||
WebWorkerObserver::WebWorkerObserver()
|
WebWorkerObserver::WebWorkerObserver()
|
||||||
: node_bindings_(NodeBindings::Create(NodeBindings::WORKER)),
|
: node_bindings_(NodeBindings::Create(NodeBindings::WORKER)),
|
||||||
atom_bindings_(new AtomBindings) {
|
atom_bindings_(new AtomBindings(node_bindings_->uv_loop())) {
|
||||||
lazy_tls.Pointer()->Set(this);
|
lazy_tls.Pointer()->Set(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +66,6 @@ void WebWorkerObserver::ContextWillDestroy(v8::Local<v8::Context> context) {
|
||||||
|
|
||||||
// Destroy the node environment.
|
// Destroy the node environment.
|
||||||
node::FreeEnvironment(env);
|
node::FreeEnvironment(env);
|
||||||
atom_bindings_.reset();
|
|
||||||
node_bindings_.reset();
|
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue