On Tue, Jun 7, 2011 at 10:02 AM, Stephan Beal <[email protected]> wrote:

> On Tue, Jun 7, 2011 at 7:50 AM, Charles Lowell 
> <[email protected]>wrote:
>
>> I noticed that if I initialize v8 in one thread, and then try and do
>> *anything* in a different thread without using a v8::Locker (even
>> ...
>
>
> To expand a tiny bit on Mads' answer: if your library-level routines will
> use a Locker, be sure that you main() (or pre-v8-setup) routine also
> contains a Locker in place. If you don't, the lib-level routines will crash
> with a


Correction: if you use an UNLocker in library-level code, be sure that at
least one Locker is in place (ideally in main() or equivalent).

A bit of background: i added a v8 binding for the C sleep() routine and it
looked something like this:

Unlocker sentry;
::sleep(...);

the point being to free up v8 for activity while sleep() was doing nothing.

The problem is that if there is no Locker in place, the Unlocker will
trigger an assertion, killing v8 and your app. When working at the
library-level, as opposed to the app level, we cannot assume that a Locker
is always in place (as that assumption causes the above code to crash the
client's app), and we have no way of knowing if one is active.

So i recommend adding a Locker to the base v8 initialization code for a
given app, since that app might run scripts which themselves run a function
(like sleep()) which uses an Unlocker.


-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to