On Fri, Dec 4, 2009 at 8:37 PM, Erik Corry <[email protected]> wrote: > 2009/12/4 Tom Brown <[email protected]>: >> I have embedded V8 into a server application as a request processing >> mechanism. Only one request is ever touching the V8 engine at any >> given time, so I'm not concerned with multi-threading. However, each > > If you are using V8 from more than one thread then you have to use the > Locker objects from v8.h. It is not enough that you only use it from > one thread at a time, you also have to use Lockers in order to tell V8 > which thread you are in.
I don't think this is not in line with what v8.h documents: http://v8.googlecode.com/svn/trunk/include/v8.h: * Multiple threads in V8 are allowed, but only one thread at a time * is allowed to use V8. The definition of 'using V8' includes * accessing handles or holding onto object pointers obtained from V8 * handles. It is up to the user of V8 to ensure (perhaps with * locking) that this constraint is not violated. * * If you wish to start using V8 in a thread you can do this by constructing * a v8::Locker object. ... This very much suggest you can use any mechanism you like, and be it "just knowing" and that v8::Locker is just one convenient one. > >> request is processed by it's own thread. It seems that any time a >> thread that is not the main thread tries to call JS code, a stack >> overflow exception is thrown. >> >> This does not happen on windows, and it does not happen with V8 >> versions 1.3.13.5 and lower. > > That is probably just luck. > >> It does happen on linux, with V8 versions 1.3.14 and higher. >> >> Due to the change log between those versions, I understand that I can >> call SetResourceConstraints before calling into V8. However, the docs > > SetResourceConstraints is used both for heap size and stack limits. > The heap size setting must be done before V8 is initialized. The > stack limits must be done while holding a lock if you are using > multiple threads. > >> say that default values will be used if this isn't called, and I'm >> concerned because the default values for new threads seem to be >> different from the default values used by the main thread. >> >> Can somebody on this list help me out by either providing an example >> of correct, threaded usage of SetResourceConstraints or by explaining >> why this is a bad idea? > > There is an example of its use in one of the tests in v8/test/cctest > > -- > Erik Corry > > -- > 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
