ffi.getCurrentEventLoop()


返回当前线程的 uv_loop_t 的地址,类型为 bigint。

🌐 Returns the address of the current thread's uv_loop_t as a bigint.

返回的地址是当前 Node.js 环境的。在主线程中,这是主线程的事件循环。在工作线程中,这是该工作线程的事件循环。

🌐 The returned address is for the current Node.js environment. In the main thread, this is the main thread event loop. In a worker thread, this is that worker's event loop.

这是不安全也很危险的。返回的指针只在当前环境的生命周期内有效。在环境退出后使用它,或者从假设不同线程或生命周期的本地代码中使用,都可能导致进程崩溃或内存损坏。

🌐 This is unsafe and dangerous. The returned pointer is only valid for the lifetime of the current environment. Using it after the environment exits, or from native code that assumes a different thread or lifetime, can crash the process or corrupt memory.