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