OZONE Asylum
Forums
DHTML/Javascript
how does set time out work?
This page's ID:
27991
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
To understand how timers and events work in script, there's a few things you need to understand: - All to me known ECMAScript engines are single threaded. - ECMAScript doesn't have any constructs for threading nor thread safety for objects. - The script engines executes "blocks of code", from start to finish, in their entirety. - The script engines are "fed" these blocks of code from the host environment (browser usually) when they should be run. Thus, when parsing an HTML file, the host will send scripts to the scripting engine as it's finished parsing/downloading them, and the script engine simply runs the block of code, from start to end, when the host tells it to. - To implement timers and events, the host environments use a scheduler and an event queue. The scheduler feeds the script engine with blocks of code gotten from this event queue. If more than one block of code is placed in this queue at the same time, the scheduler will give the blocks to the script engine for execution in the order they were placed in the queue. This is all about-ish. There is more happening below the surface, we have many types of events that are internal to the host, the host may have priority balancing schedulers etc. The reason setTimeout and setInterval are not part of the ECMAScript specification is just this - the timer events are strongly bound to the host environment, and have to be handled by the host. -- var Liorean = { abode: "[sigrotate][url]http://liorean.web-graphics.com/[/url]|[url]http://codingforums.com/[/url]|[url]http://web-graphics.com/[/url][/sigrotate]", profile: "[url]http://codingforums.com/member.php?u=5798[/url]"};
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »