I have a program that uses boost streams. The program has start and stop functions. When the program starts, I create a boost thread that does some processing. When the program is stopped, I call the connection in this thread and delete the thread pointer. My program starts and stops correctly for the first time; however, when I try to run my program a second time, I cannot argue inside boost (when creating the processing thread), and the following is displayed on my screen:
/root/src/boost.cmake/libs/thread/src/pthread/once.cpp:46: unsigned long &boost::detail::get_once_per_thread_epoch(): Assertion`!pthread_setspecific(epoch_tss_key,data)' failed.
I know that my connection is working correctly, because when the processing flow ends, I was displaying a message on my console. Does anyone know why this might happen?
Additional note ... I played a little with my code, and the methodology that I use to clean up the boost threads works in other parts of my program (for example, if I create a :: thread impulse in the parent class). However, it fails every time in a child class (which is an abstract class).
My start and stop methods look like this:
void ThreadMethod()
{
while(_runningThread)
{
}
}
void Start()
{
_runningThread = true;
_thread = boost::make_shared<boost::thread>(&TestChildVirtualClass::ThreadMethod, this);
};
void Stop()
{
_runningThread = false;
_thread->join();
if( _thread )
{
_thread.reset();
}
};
However, it is difficult for me to recreate this problem in a test program (although this happens every time in my real program).
source
share