{ "source": "doc/api/timers.markdown", "modules": [ { "textRaw": "Timers", "name": "timers", "stability": 5, "stabilityText": "Locked", "desc": "
All of the timer functions are globals. You do not need to require()
\nthis module in order to use them.\n\n
To schedule execution of a one-time callback
after delay
milliseconds. Returns a\ntimeoutId
for possible use with clearTimeout()
. Optionally you can\nalso pass arguments to the callback.\n\n
It is important to note that your callback will probably not be called in exactly\ndelay
milliseconds - Node.js makes no guarantees about the exact timing of when\nthe callback will fire, nor of the ordering things will fire in. The callback will\nbe called as close as possible to the time specified.\n\n
Prevents a timeout from triggering.\n\n
\n", "signatures": [ { "params": [ { "name": "timeoutId" } ] } ] }, { "textRaw": "setInterval(callback, delay, [arg], [...])", "type": "method", "name": "setInterval", "desc": "To schedule the repeated execution of callback
every delay
milliseconds.\nReturns a intervalId
for possible use with clearInterval()
. Optionally\nyou can also pass arguments to the callback.\n\n
Stops a interval from triggering.\n\n
\n", "signatures": [ { "params": [ { "name": "intervalId" } ] } ] }, { "textRaw": "unref()", "type": "method", "name": "unref", "desc": "The opaque value returned by setTimeout
and setInterval
also has the method\ntimer.unref()
which will allow you to create a timer that is active but if\nit is the only item left in the event loop won't keep the program running.\nIf the timer is already unref
d calling unref
again will have no effect.\n\n
In the case of setTimeout
when you unref
you create a separate timer that\nwill wakeup the event loop, creating too many of these may adversely effect\nevent loop performance -- use wisely.\n\n
If you had previously unref()
d a timer you can call ref()
to explicitly\nrequest the timer hold the program open. If the timer is already ref
d calling\nref
again will have no effect.\n\n
To schedule the "immediate" execution of callback
. Returns an immediateId
\nfor possible use with clearImmediate()
. Optionally you can also pass\narguments to the callback.\n\n
Immediates are queued in the order created, and are popped off the queue once\nper loop iteration. This is different from process.nextTick
which will\nexecute process.maxTickDepth
queued callbacks per iteration. setImmediate
\nwill yield to the event loop after firing a queued callback to make sure I/O is\nnot being starved. While order is preserved for execution, other I/O events may\nfire between any two scheduled immediate callbacks.\n\n
Stops an immediate from triggering.\n
\n", "signatures": [ { "params": [ { "name": "immediateId" } ] } ] } ], "type": "module", "displayName": "Timers" } ] }