【文件属性】:
文件名称:interruptor:运行一个函数,有可能被另一个线程中断
文件大小:11KB
文件格式:ZIP
更新时间:2021-04-11 20:40:01
C++
中断器–运行一个函数,可以从另一个线程中断它
使用范例
import { runInterruptible , interrupt } from 'interruptor' ;
runInterruptible ( handle => {
// pass handle to another thread using .postMessage();
while ( true ) ;
} ) ;
// In another thread:
interrupt ( handle ) ;
注意事项
这是一个本机加载项,目前尚无预构建的二进制文件。
这只会中断回调内部的同步执行,不会中断异步函数(尽管Node.js 14及更高版本中vm模块的microtaskMode选项可以在此处帮助实现Promises)。
这不会完全中断正在运行的代码,也不会运行任何catch或finally块。 特
【文件预览】:
interruptor-main
----.eslintrc(312B)
----package.json(2KB)
----.github()
--------workflows()
----test()
--------index.ts(955B)
----LICENSE(11KB)
----src()
--------binding.cc(3KB)
--------index.ts(512B)
----tsconfig.json(407B)
----.gitignore(286B)
----CODE_OF_CONDUCT.md(3KB)
----README.md(838B)
----binding.gyp(95B)