setInterval & setTimeout

592 views
Skip to first unread message

Ned

unread,
Jun 2, 2009, 11:11:39 AM6/2/09
to v8-users
As long as I can see there is no setInterval & setTimeout functions in
V8 because they are bound to "window" object in KHTML...

My question is - have some of you guys written or does someone know is
there a code that could add such a behavior to V8. I really need this
behavior.

Regards
Nedko

ps I honestly can't imagine real javascript without setInterval &
setTimeout

Dean McNamee

unread,
Jun 2, 2009, 11:16:11 AM6/2/09
to v8-u...@googlegroups.com
These concepts are driven around the concept of a main event loop.
This concept is specific to browsers, and not to JavaScript. It would
all depend how you embed the JavaScript engine, and if you want to
structure it around an event loop with timers, etc.

-- dean

Ned

unread,
Jun 2, 2009, 11:23:12 AM6/2/09
to v8-users
Thank you Dean... and yet some directions on how to implement it?

Sébastien Pierre

unread,
Jun 2, 2009, 3:18:43 PM6/2/09
to v8-u...@googlegroups.com
You'd probably have to add an event loop and have a timer thread insert callbacks into the loop. You could use things like libevent to do that.

 -- Sébastien

Ned

unread,
Jun 3, 2009, 3:01:56 AM6/3/09
to v8-users
Thank you Sébastien for your reply,
I would guess how to implement the event thread but how do I interrupt
the execution of the script thread so I could force the execution of a
particular script code. That's what I don't know. Could you or someone
else please provide some details about it?

Thank you
Nedko

On Jun 2, 10:18 pm, Sébastien Pierre <sebastien.pie...@gmail.com>
wrote:

Erik Corry

unread,
Jun 3, 2009, 3:59:26 AM6/3/09
to v8-u...@googlegroups.com
2009/6/3 Ned <nedko....@gmail.com>:
>
> Thank you Sébastien for your reply,
> I would guess how to implement the event thread but how do I interrupt
> the execution of the script thread so I could force the execution of a
> particular script code. That's what I don't know. Could you or someone
> else please provide some details about it?

The way it works in a browser is there is only one thread. The
scripts are never interrupted, but are expected to return to the event
loop after a reasonably short time, possibly scheduling another
callback first.
--
Erik Corry, Software Engineer
Google Denmark ApS. CVR nr. 28 86 69 84
c/o Philip & Partners, 7 Vognmagergade, P.O. Box 2227, DK-1018
Copenhagen K, Denmark.
Reply all
Reply to author
Forward
0 new messages