timeout.unref()
- 返回: <Timeout>
timeout
的引用
调用时,活动的 Timeout
对象不需要 Node.js 事件循环保持活动状态。
如果没有其他活动保持事件循环运行,则进程可能会在调用 Timeout
对象的回调之前退出。
多次调用 timeout.unref()
将不起作用。
调用 timeout.unref()
创建内部的定时器,其将唤醒 Node.js 事件循环。
创建过多的这些会对 Node.js 应用程序的性能产生不利影响。
- Returns: <Timeout> a reference to
timeout
When called, the active Timeout
object will not require the Node.js event loop
to remain active. If there is no other activity keeping the event loop running,
the process may exit before the Timeout
object's callback is invoked. Calling
timeout.unref()
multiple times will have no effect.
Calling timeout.unref()
creates an internal timer that will wake the Node.js
event loop. Creating too many of these can adversely impact performance
of the Node.js application.