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
fixed styling nits identified by @mscdex
  • Loading branch information
techjeffharris committed Feb 24, 2016
commit 254694bc5f73356e96f100d5bda301a54af1940b
6 changes: 3 additions & 3 deletions doc/topics/the-event-loop-timers-and-nexttick.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ time thresholds have been reached_. If one or more timers are ready, the
event loop will wrap back to the timers phase to execute those timers'
callbacks.

### `setImmediate()`:
### `setImmediate`:

`setImmediate()` is actually a special timer that runs in a separate phase of
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure that I would call it a timer really since it has no "timeout" value per se ...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just used @trevnorris' words from the presentation link in the OP, but I am open so suggestions as per his approval.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its a timer? really? that surprises me, its behaviour seems unrelated to time.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure timer is good terminology for it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH, I do not have enough intimate knowledge of the codebase to argue for or against whether or not it is a timer. I just said its a special form of timer because that's what I got from the presentation which was the basis. I'm hoping to get this landed ASAP, so that EVERYONE can discuss and refine this doc

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

setImmediate is not a timer, see #4936 (comment). However if we do not clarify that there is a step for executing setImmediate tasks, we have no way of clarifying the difference.

the event loop. It uses a libuv API that schedules callbacks to execute after
Expand Down Expand Up @@ -281,7 +281,7 @@ To get around this the `'listening'` event is queued in a `nextTick()` to allow
the script to run to completion. Which allows the user to set any event
handlers they want.

## process.nextTick() vs `setImmediate()`
## `process.nextTick()` vs `setImmediate()`

We have two calls that are similar as far as users are concerned, but their
names are confusing.
Expand Down Expand Up @@ -322,7 +322,7 @@ server.on('listening', function() { });
```

Say that listen() is run at the beginning of the event loop, but the
listening callback is placed in a setImmediate. Now, unless a hostname
listening callback is placed in a `setImmediate()`. Now, unless a hostname
is passed binding to the port will happen immediately. Now for the
event loop to proceed it must hit the `poll` phase, which means there
is a non-zero chance that a connection could have been received allowing
Expand Down