port.ref()


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

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

Opposite of unref(). Calling ref() on a previously unref()ed port does 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 has no effect.

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