On Sun, Apr 28, 2013 at 12:07 PM, danijar <[email protected]> wrote:
> I want to use only a single v8::Context for my whole application, so that I
> can access registered callbacks from everywhere. I tried simple always using
> v8::Context::GetCurrent() but I crashes if I haven't created a context
> before manually. To create a new context, I can use v8::Context::New() but I
> want to call I only, if there isn't a current context already.
>
> I tried checking if the returned handle is emtpy but instead of returning an
> empty handle, it just crashes.
>
> v8::Handle<v8::Context> handle = v8::Context::GetCurrent();
> if(!handle)
> {
>     handle = v8::Context::New();
> }
>
> So how can I check if there is a current context already? Or is there a
> better way to access functions bound to various contexts from within a
> single script?

Create your Context at initialization time.  There is really no other
way because everything in V8 runs in the scope of a Context.

See https://developers.google.com/v8/embed#contexts for more details.

-- 
-- 
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/groups/opt_out.


Reply via email to