1
0
Fork 0

check for CREATED on shutdown

This commit is contained in:
Frank Celler 2016-02-22 22:48:30 +01:00
parent 963578180a
commit 8a473c1f5b
1 changed files with 6 additions and 0 deletions

View File

@ -182,6 +182,12 @@ void Thread::beginShutdown() {
void Thread::shutdown(bool waitForStopped) {
LOG_TOPIC(TRACE, Logger::THREADS) << "shutdown(" << _name << ")";
ThreadState state = _state.load();
while (state == ThreadState::CREATED) {
_state.compare_exchange_strong(state, ThreadState::STOPPED);
}
if (_state.load() == ThreadState::STARTED) {
beginShutdown();