Well, I was talking about data access from two threads running JS with preemption enabled.
Consider a doubly linked list, like this: https://github.com/mschwartz/SilkJS/blob/dev/modules/List.js If one thread calls each() and another is calling remove(), each() will fail if the remove() is preempted before both assignments are done. On Jul 2, 2012, at 10:52 AM, Pablo Sole wrote: > > 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 -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
