On Thu, May 10, 2018 at 10:24 PM, Jane Chen <jxche...@gmail.com> wrote:
> Embedding v8 v5.3.
>
> Is there any way to reset global object for a context so that the context
> can be re-used?
>
> How is Context::DetachGlobal() is meant to be used?
>
> Thanks,
> Jane

You can't reset a context but you can detach the global object and
create a new context with it.  It will revert to its pristine state in
the new context.  In a nutshell:

    auto global = old_context->Global();
    old_context->Exit();  // Need to exit the context before detaching.
    old_context->DetachGlobal();
    auto new_context = v8::Context::New(global->GetIsolate(),
v8::Local<v8::ObjectTemplate>(), global);

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
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 v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to