I have a strange problem with Boost 1.54 threads which seem to block when the thread object goes out of scope.
Background: I'm working on a real-time application that uses external hardware through API calls. Some of these API calls block until execution. That's why I want to call them in separate threads in order to avoid blocking my main thread. The simplified structure looks as follows:
void some_func(){
//t2
boost::thread t(&blocking_call);
//t3
}
int main(){
//t1
some_func();
//t4
return 0;
}
Luckily, the external hardware has an onboard clock so that I was able to time the execution of my program precisely.
What I observed: t1, t2 and t3 are - as expected - incrementing only a tiny little bit, but t4 is always shortly after the execution time of the API call which is a lot later (and unfortunately even too late for me). It seems as if the thread object was calling join() when it is going out of scope, although I thought it should just get detached and finish its work.
Any hints what might be the issue?