On Thu, Jun 23, 2011 at 7:35 PM, Marcel Laverdet <[email protected]>wrote:
> Peep the Locker documentation.

i've read all 7 lines of them (that's not an exaggeration).

Basically there's a special case so that if you're using v8 in a single
> thread, that thread is always considered "locked". But if you ever need to
> invoke v8 from a different thread you must lock and unlock. But if you're
> using Isolates that would imply you need more than one thread, because
> there's nothing that Isolate get you that Context doesn't.. beside
> multi-thread support.
>

i'm not explicitly using Isolates, but the API docs imply that i really am
(under the hood). i'm also not using threads, but i'm writing library-level
code which _might_ be used by clients using threads, and thus i make use of
Unlocker where it would make sense to do so in an application. e.g. when
binding C's sleep() function to JS, we can/should unlock while sleeping.
When running in single thread mode (with an _implicit_ lock), using an
Unlocker asserts, and thus i've always worked around it by requiring that
client apps include an explicit Locker somewhere above where their scripts
run my lib's code (e.g. when they set up their context).

Thus it appears that the "implicit lock" (which, according to the Isolate
docs, is explicit) is not a lock in a technical sense, but in the sense of
"there's only one thread, so it is in effect locked." Is that correct?

To be clear: i'm not calling this a v8 defect/design flaw, but maybe there's
some misleading wording in the documentation. The Isolate docs state
(indirectly, via the logical implications of what they do say directly: that
an Isolate is Entered and that Entry requires a Locker) that a Locker is in
place whenever v8 is initialized, but that does not appear to be the case
because Unlocker asserts when used without an active client-instantiated
Locker. If there is a Locker in place implicitly (as the API docs suggest),
then Unlocking it wouldn't assert, i think.

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

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

Reply via email to