Can not restart thread
Hi,
I just discover the problem which I think is a bug in IceE 1.3.0 (discovered on Linux but I think it is platform independent). Here is the problem description.
I have an instance of my class derived from IceUtil::Thread. In the application I need to start and stop the thread several times during application life cycle. I implemented it with simple bool flag as following:
void MyThread::run()
{
while(!this->shutdown_requested)
// do the job
}
Everything works fine but attempt to start the thread second time (using the same MyThread instance) throws ThreadStartedException.
Looking at the IceUtil::Thread::start(...) function, I can see that this exception throwed if(_started) condition is true. However I did not find the place where _started is set to false if the thread run() function exited. Only _running attribute is changed in _done() function. That is why, second attempt to start the thread throws the exception.
Fortunatelly, _started flag is protected attribute so if I set it to false at the end of my run() function, then everything works fine and I can restart the thread without any problems. I do not see any reasons why the same thread object instance could not be used several times and that is why think that this is a bug. It should be very easy to fix for example by assigning false to _started in _done() function.
Regards,
Andrey.
Andrey Nechypurenko
GE Healthcare