LoginSignup
17
11

More than 5 years have passed since last update.

setImmediate()とnextTick()なにが違うの

Last updated at Posted at 2015-07-03

結論

どちらも処理を次のイベントループに追加する。

違いは
- setImmediate(): IO処理の後
- nextTick(): IO処理の前

迷ったらsetImmediate()使っとけばいいいと思う。

参照

http://jxck.hatenablog.com/entry/for-with-eventloop
これ見ればよい。

要は、I/O処理より先に呼ばれるのがnextTickで後に呼ばれるのがsetImmediate。
eventloopの効率利用を考えると先にI/0処理したいので、setImmediate()を選択しとけば間違いなさそう。

17
11
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
11