Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
46f0702
doc: add topic - event loop, timers, `nextTick()`
techjeffharris Jan 28, 2016
5a28415
doc: add topic - event loop, timers, `nextTick()`
techjeffharris Jan 28, 2016
dc1b8a5
corrections suggested in the GitHub PR
techjeffharris Jan 29, 2016
bb5b682
Merge branch 'doc-topic-event-loop-timers-nextTick' of github.com:tec…
techjeffharris Jan 29, 2016
ba98380
removed file without .md extension
techjeffharris Jan 29, 2016
936bf17
add details to explanation of timers
techjeffharris Jan 29, 2016
35cf726
update to address comments on PR
techjeffharris Feb 17, 2016
f80d7cc
fixed typo, added example as per @trevnorris
techjeffharris Feb 24, 2016
254694b
fixed styling nits identified by @mscdex
techjeffharris Feb 24, 2016
45fb2fe
fixes suggested by @silverwind and @fishrock123
techjeffharris Feb 26, 2016
d6d76f5
addressed comments made on GH issue
techjeffharris Mar 25, 2016
c133caf
updated `setImmediate()` vs `setTimeout()` section
techjeffharris Mar 25, 2016
f425164
update overview, phase detail headings, wrap at 72
techjeffharris Mar 29, 2016
1bd3e6c
docs: minor nits on the libuv phases.
mcollina Mar 31, 2016
7574d4b
Removed second timer phase.
mcollina Mar 31, 2016
8dc6ecb
Merge pull request #1 from mcollina/doc-topic-event-loop-timers-nextTick
techjeffharris Mar 31, 2016
d82a7f1
fix nits presented by @ajafff
techjeffharris Mar 31, 2016
1dc26f6
fix backticks on line 205
techjeffharris Mar 31, 2016
82d0fb8
Improve wording `setTimeout()` vs `setImmediate()`
techjeffharris Apr 7, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Removed second timer phase.
  • Loading branch information
mcollina committed Mar 31, 2016
commit 7574d4b18f32efd1db19ac7da539e5d57467ee7e
12 changes: 1 addition & 11 deletions doc/topics/the-event-loop-timers-and-nexttick.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ order of operations.
│ │ check │
│ └──────────┬────────────┘
│ ┌──────────┴────────────┐
│ │ close callbacks │
│ └──────────┬────────────┘
│ ┌──────────┴────────────┐
└──┤ timers │
└──┤ close callbacks │
└───────────────────────┘

*note: each box will be referred to as a "phase" of the event loop.*
Expand Down Expand Up @@ -77,7 +74,6 @@ actually uses are these four._
* `poll`: retrieve new I/O events; node will block here when appropriate
* `check`: setImmediate callbacks are invoked here
* `close callbacks`: e.g socket.on('close', ...)
* `timers`: indeed, again

Between each run of the event loop, Node.js checks if it is waiting for
any asynchronous I/O or timer and it shuts down cleanly if there are not
Expand Down Expand Up @@ -212,12 +208,6 @@ If a socket or handle is closed abruptly (e.g. `socket.destroy()`), the
`'close'` event will be emitted in this phase. Otherwise it will be
emitted via `process.nextTick()`.

### `timers` again

Timers are checked twice to reduce the drift between the expected time
and the actual execution time, as more code is executed between two
loop runs.

## `setImmediate()` vs `setTimeout()`

`setTimeout()` is designed to execute a script after a minumum threshold
Expand Down