On 07/02/2012 01:00 PM, Michael Schwartz wrote:
> Wow, that's a great tip.  I implemented it and long running threads work fine 
> and get preempted.
Glad to help!
> I guess the disadvantage is thread safety and synchronization of data 
> accesses.  I'm not clear on when a thread running in v8 might be preempted.  
> Likely on entering or exiting functions (when doing stack checks, I think I 
> remember reading about).
AFAIK, any StackGuard instance is preemptible, regex matching also check
for preemption, some loops and there must be some other places too. This
mechanism is used by chromium, I suppose, to switch between Contexts
(frames/iframes) of a same tab (Isolate?). I'm completely making this up
and it's probably not accurate, but must be something like that :).

The rule of thumb for thread safety should be to not trust on a Locker
instance (which can be preempted) for any resource sync managed or
potentially modified from outside of v8. A C++ function wrapped inside a
FunctionTemplate though, cannot be preempted of course, so that's safe.

pablo.

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

Reply via email to