想象一下,我使用 Node.js 插件中的同步函数:
var check_ok = addon.my_function(parameters);
var final_results = addon.final_function(parameters);
但是在方法代码中我有:
std::thread t[10]; //Global
//...
void my_function(const FunctionCallbackInfo<v8::Value>& args) {
//....
t[0] = thread(random_void_function, [parameters])
t[1] = thread(random_void_function_2, [parameters])
//...
}
//...
void final_results(const FunctionCallbackInfo<v8::Value>& args) {
//...
t[0].join();
t[1].join();
//...Give results.. etc
}
所以我有2个插件的同步调用,但在这个插件中使用了两个线程。一个函数将启动线程,另一个函数将加入它们。问题是:random_void_function
会random_void_function_2
并行运行吗?由于my_function
andfinal_function
是同步的,random_void_function
andrandom_void_function_2
会阻塞事件循环吗?据我所知,他们没有阻止。