port.ref()


unref() 的相反。 如果它是唯一剩下的活动句柄(默认行为),则在以前的 unref() 的端口上调用 ref() 不会让程序退出。 如果端口是 ref() 的,则再次调用 ref() 将无效。

如果使用 .on('message') 绑定或删除监听器,则端口将根据事件的监听器是否存在自动进行 ref()unref()

Opposite of unref(). Calling ref() on a previously unref()ed port will not let the program exit if it's the only active handle left (the default behavior). If the port is ref()ed, calling ref() again will have no effect.

If listeners are attached or removed using .on('message'), the port will be ref()ed and unref()ed automatically depending on whether listeners for the event exist.