On Fri, May 13, 2011 at 12:57 PM, Matthias Ernst <[email protected]>wrote:
> Avoid it in the first place. If you admit to yourself that only one > piece of JS can only ever execute at a time, you can implement this > simply using a priority queue and a single-threaded C++ main loop like > this: > i agree completely with your summary, BUT... the code linked above is library-level, not application-level, and the library has no event loop model (nor would it benefit from one except as a way to implement setTimeout() and friends in a browser-compliant manner). So this would seem to be the only workaround for implementing setTimeout() (or something "close to it with some threading caveats") in v8. > This is nothing different from what node does, except from that > "timers" is "timers and io interests" and "sleep" is "select with > timeout". > Nodejs is a full-fledged framework upon which clients are expected to write their apps. v8-juice is a "glue" library built to assist in binding non-v8 code to v8 (and not to wedge itself between v8 and the client). Since my code is more or less glue, and not a framework, the only option i found for implementing setTimeout() was using threads. That said, i recently implemented a poll() function for v8 which could be used to implement a main loop from JS, and from there we could use the MockTimers JS code to implement setTimeout() in a more browser-compliant manner. http://code.google.com/p/v8-juice/wiki/PluginPosixPoll http://code.google.com/p/v8-juice/source/browse/extra-plugins/src/PosixPoll/PosixPoll.cpp Side note: a side-effect of the Locker model is that adding Unlocker-using support in v8-using _libraries_ (as opposed to applications) is impossible without some application-side help. The main() routine has to establish a Locker or library-level code cannot legally later use Unlocker. -- ----- stephan beal http://wanderinghorse.net/home/stephan/ -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
