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 つありますが、このアドオンでは 2 つのスレッドが使用されます。1 つの関数がスレッドを開始し、もう 1 つの関数がそれらに参加します。質問は次のとおりです。並行して実行されますかrandom_void_function
? とは同期しているrandom_void_function_2
ので、とはイベント ループをブロックしますか? 私が見たところ、彼らはブロックしません。my_function
final_function
random_void_function
random_void_function_2