Hi Guy, Please note that isolates and threads are in fact orthogonal. An isolate is a separate instance of a VM (VM state), as a thread is a separate control flow. So actually you can have multiple isolates in the same thread, as well as multiple threads working with the same isolate. But isolates are not thread safe, so in the latter case you need a locker to synchronize access from multiple threads. That's it.
On Wed, Feb 8, 2012 at 21:54, Guy X. Smiley <[email protected]> wrote: > OK, here's how I understand it. Gurus, please correct me if I'm wrong. > > V8 supports three modes of operation - thread-oblivious, thread-safe, > and > multi-isolate (my terms). Thread-oblivious means you always use the > default > isolate and don't bother with locks. This is the default mode and is > safe for > single-threaded applications. > > By instantiating a locker, however, you're switching into thread-safe > mode, and > from that point on must always use a locker when accessing V8. > > But that's not enough. Presumably you're using thread-safe mode > because your > application is multi-threaded. To use V8 from a given thread, not only > must you > lock the relevant isolate, but the thread must also enter that > isolate. This is > the "assist" that thread-safe mode provides over full-blown multi- > isolate mode; > when you lock the default isolate, the current thread automatically > enters > it; when you unlock it, the current thread automatically exits it. > > So when your first locker goes out of scope, not only does it unlock > the > default isolate, but it also causes the thread to exit it, and that > causes it > to discard its record of the currently entered context. > > > On Feb 7, 12:46 pm, cruisercoder <[email protected]> wrote: >> The code below assets with the error "cannot exit non-entered context" >> and occurs in v8 versions 3.1.8 and 3.6.2. Can anyone indicate why? >> >> { >> using namespace v8; >> >> Persistent<Context> context; >> >> { >> Locker l; >> HandleScope handle_scope; >> context = Persistent<Context>::New(Context::New()); >> context->Enter(); >> } >> >> { >> Locker l; >> context->Exit(); >> context.Dispose(); >> } >> >> } >> >> # >> # Fatal error in v8::Context::Exit() >> # Cannot exit non-entered context >> # > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
