isolates: have node::Isolate manage the v8::Context

This commit is contained in:
Ben Noordhuis committed 2011-12-29 01:56:10 +01:00
1 parent ea97d6ed5f
commit ca19e792c6
2 files changed
+18

No files matched your search

+12
View File
@@ -47,6 +47,9 @@ Isolate::Isolate(uv_loop_t* loop) {
assert(v8_isolate_->GetData() == NULL);
v8_isolate_->SetData(this);
v8_context_ = v8::Context::New();
v8_context_->Enter();
globals_init(&globals_);
}
@@ -77,6 +80,15 @@ void Isolate::Dispose() {
it->callback_(it->arg_);
delete it;
}
assert(v8_context_->InContext());
v8_context_->Exit();
v8_context_.Clear();
v8_context_.Dispose();
v8_isolate_->Exit();
v8_isolate_->Dispose();
v8_isolate_ = NULL;
}
+6
View File
@@ -62,6 +62,11 @@ public:
return v8_isolate_;
}
v8::Handle<v8::Context> GetV8Context() {
NODE_ISOLATE_CHECK(this);
return v8_context_;
}
/* Register a handler that should run when the current isolate exits.
* Handlers run in LIFO order.
*/
@@ -82,6 +87,7 @@ private:
};
SLIST_HEAD(AtExitCallbacks, AtExitCallbackInfo) at_exit_callbacks_;
v8::Persistent<v8::Context> v8_context_;
v8::Isolate* v8_isolate_;
uv_loop_t* loop_;