我正在尝试使用 Node 的worker_threadsusing node-worker-threads-pool(包装器)包及其DynamicPool.
我的问题是,执行一个线程给一个具有imports 的函数将不起作用,因为该函数将是undefined.
// moduleA.js
import xyz from './xyz.js'
const f = x => {
xyz () //<-- f is undefined
}
export default f
// moduleB.js
import f from './moduleA.js'
f (1) //
// moduleC.js
const x = await pool.exec ({
task: f
})
这是特定问题 node-worker-threads-pool还是 Node问题worker_threads?您知道解决此问题的一些方法吗?