Imagine that I use a 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]; //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
}
So I have 2 synchronous calls of addon, but in this addon two threads are used. One function will start the threads and the other will join them. The questions are: random_void_function
and random_void_function_2
will run in parallel? Since my_function
and final_function
are synchronous, the random_void_function
and random_void_function_2
will block the event loop? From what I see, they not block.