Imagine using the synchronous function from my Node.js addon:
var check_ok = addon.my_function(parameters);
var final_results = addon.final_function(parameters);
But in the method code, I have:
std::thread t[10];
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();
}
So, I have 2 synchronous addon calls, but this addon uses two threads. One of the functions will start the threads, and the other will join them. Questions: random_void_functionand random_void_function_2will work in parallel? Since my_functionthey final_functionare both synchronous random_void_functionand random_void_function_2block the event loop? From what I see, they are not blocked.
source
share