domain.enter()


enter() 方法是 run()bind()intercept() 方法用来设置活动域的管道。 它将 domain.activeprocess.domain 设置为域,并将域隐式推送到域模块管理的域堆栈上(有关域堆栈的详细信息,请参见 domain.exit())。 对 enter() 的调用界定了一系列异步调用和绑定到域的 I/O 操作的开始。

调用 enter() 只改变活动域,不改变域本身。 enter()exit() 可以在单个域上调用任意次数。

The enter() method is plumbing used by the run(), bind(), and intercept() methods to set the active domain. It sets domain.active and process.domain to the domain, and implicitly pushes the domain onto the domain stack managed by the domain module (see domain.exit() for details on the domain stack). The call to enter() delimits the beginning of a chain of asynchronous calls and I/O operations bound to a domain.

Calling enter() changes only the active domain, and does not alter the domain itself. enter() and exit() can be called an arbitrary number of times on a single domain.