SungchulCho / v8-juice

Automatically exported from code.google.com/p/v8-juice
Other
0 stars 0 forks source link

setTimeout() needs to be reimplemented #20

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
The current implementation of setTimeout() runs the timeout code in a 
separate thread. Browser implementations interrupt the main thread, run the 
timeout code to completion, and then return control to the main thread (or 
that's what the guys on v8-user tell me). The latter approach is much safer, 
since JS doesn't give us any synchronization tools.

To be honest, though, i'm not quite sure how it might be reimplemented to 
work that way. :/

Any help from a threading expert out there would be much appreciated!

Original issue reported on code.google.com by sgbeal@googlemail.com on 2 Apr 2010 at 10:30

GoogleCodeExporter commented 8 years ago
this implementation looks like it will make a good replacement:

http://github.com/visionmedia/js-mock-timers/

it requires a tiny bit of refactoring and the addition of a thread to run the 
"time
generator", but it's an excellent basis to work from.

Original comment by sgbeal@googlemail.com on 8 Apr 2010 at 9:10

GoogleCodeExporter commented 8 years ago
Current state: in the source tree i've copied setTimeout() to 
spawnTimeoutThread() 
(same for the other functions). setTimeout() will probably be removed from the 
native 
code, and i'll instead provide something based on:

http://code.google.com/p/v8-
juice/source/browse/branches/edge/src/client/shell/js/MockTimer.js

which is a forked/updated copy of the above-linked mock-timers code.

Original comment by sgbeal@googlemail.com on 9 Apr 2010 at 2:25

GoogleCodeExporter commented 8 years ago

Original comment by sgbeal@googlemail.com on 7 Jun 2010 at 9:59