- Mastering Node.js(Second Edition)
- Sandro Pasquali Kevin Faaborg
- 109字
- 2021-07-02 19:28:43
Deferred execution
One occasionally needs to defer the execution of a function. Traditional JavaScript uses timers for this purpose, with the well-known setTimeout and setInterval functions. Node introduces another perspective on defers, primarily as means of controlling the order in which a callback executes in relation to I/O events, as well as timer events properly.
As we saw earlier, managing timers is one of the main jobs of Node's event loop. Two types of deferred event sources that give a developer the ability to schedule callback executions to occur either before, or after, the processing of queued I/O events are process.nextTick and setImmediate. Let's look at those now.
推薦閱讀
- 通信網絡基礎與設備
- Mastering Machine Learning for Penetration Testing
- Building Django 2.0 Web Applications
- 電子政務效益的經濟分析與評價
- 網絡互聯技術(實踐篇)
- 無人機通信
- 電力物聯網工程技術原理與應用
- 企業網絡安全管理
- 區塊鏈輕松上手:原理、源碼、搭建與應用
- Yii Application Development Cookbook(Second Edition)
- 物聯網技術與應用
- Windows Server 2012 Hyper-V虛擬化管理實踐
- 網絡安全應急響應技術實戰指南
- jQuery Mobile Web Development Essentials
- 設備監控技術詳解