On Thu, Nov 20, 2014 at 12:48 AM, Robert Jenks <[email protected]>
wrote:
> [...] class Jav8Context {
> public:
> Jav8Context() {
> // Create a new Isolate and make it the current one.
> isolate_ = v8::Isolate::New();
> v8::Isolate::Scope isolateScope(isolate_);
> isolate_->Enter();
> v8::HandleScope handleScope(isolate_);
> v8::Handle<v8::Context> ctxt = v8::Context::New(isolate_);
> ctxt->Enter();
> context_ = new v8::Persistent<v8::Context>(isolate_, ctxt);
> }
> ~Jav8Context() {
> context_->Reset();
> isolate_->Exit();
> isolate_->Dispose();
> }
> v8::Isolate* GetIsolate() {return isolate_;}
> v8::Persistent<v8::Context>* GetContext() {return context_;}
> private:
> v8::Isolate* isolate_;
> v8::Persistent<v8::Context>* context_;
> };
>
Just a few quick remarks:
* Isolate::Scope already does the Enter/Exit for you, so using
Enter/Exit explicitly, too, looks fishy.
* There is no call to context_->Exit() AFAICT.
* If Jav8Context is intended to be stack-allocated, then handling
Enter/Exit there is OK. OTOH if it is intended to used via new/delete,
having Enter/Exit in it will normally make your life harder and is a source
of bugs.
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.