Hello, v8 gurus! i am re-examining some threaded code and i came across a question regarding a _possible_ corner-case when using Locker(), Unlocker() and V8::IsDead()...
i have a setTimeout()-like implementation: http://code.google.com/p/v8-juice/source/browse/branches/edge/src/lib/juice/time.cc i start up a new thread (i know this isn't browser-like, which runs setTimeout() handlers in the main thread, but that's besides the point), then i do the following in my thread: a) Instantiate a Locker b) Instantiate a HandleScope c) Run a loop where i: 1) Instantiate an Unlocker(), so that v8 can take control when i... 2) sleep for the timeout period 3) wake up, check for timer cancellation and V8::IsDead() 4) run the timeout function (if appropriate) At various points i check to see if the time has been removed or if v8::V8::IsDead(), so i can abort the loop or avoid calling the timeout function, and a mutex is used to control access to the timer ID list. Now my question is: If main() exits and v8 is cleaned up while the sleep() is running, and then my timeout wakes up, do Locker, Unlocker, and HandleScope die gracefully if V8::IsDead() and my function returns (triggering their dtors), or will they crap out because v8 is no longer active? If the answer is "they'll crap out", is there ANY possible safe way to bail out in this case? Many thanks for your consideration, and Happy Hacking! -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
