domain.exit()


exit() 方法退出当前域,将其从域堆栈中弹出。每当执行将切换到不同异步调用链的上下文时,确保当前域已被退出是很重要的。调用 exit() 标志着绑定到域的异步调用链和 I/O 操作的结束或中断。

【The exit() method exits the current domain, popping it off the domain stack. Any time execution is going to switch to the context of a different chain of asynchronous calls, it's important to ensure that the current domain is exited. The call to exit() delimits either the end of or an interruption to the chain of asynchronous calls and I/O operations bound to a domain.】

如果有多个嵌套的域绑定到当前执行上下文,exit() 将退出嵌套在该域内的任何域。

【If there are multiple, nested domains bound to the current execution context, exit() will exit any domains nested within this domain.】

调用 exit() 只会改变当前活动的域,并不会修改域本身。enter()exit() 可以在同一个域上任意次数地调用。

【Calling exit() 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.】