|
@ -69,17 +69,14 @@ void Worker::startWorking() |
|
|
if (ex == WorkerState::Killing || ex == WorkerState::Starting) |
|
|
if (ex == WorkerState::Killing || ex == WorkerState::Starting) |
|
|
m_state.exchange(ex); |
|
|
m_state.exchange(ex); |
|
|
|
|
|
|
|
|
// cnote << "Waiting until not Stopped...";
|
|
|
while (m_state == WorkerState::Stopped) |
|
|
DEV_TIMED_ABOVE("Worker stopping", 100) |
|
|
this_thread::sleep_for(chrono::milliseconds(20)); |
|
|
while (m_state == WorkerState::Stopped) |
|
|
|
|
|
this_thread::sleep_for(chrono::milliseconds(20)); |
|
|
|
|
|
} |
|
|
} |
|
|
})); |
|
|
})); |
|
|
// cnote << "Spawning" << m_name;
|
|
|
// cnote << "Spawning" << m_name;
|
|
|
} |
|
|
} |
|
|
DEV_TIMED_ABOVE("Start worker", 100) |
|
|
while (m_state == WorkerState::Starting) |
|
|
while (m_state == WorkerState::Starting) |
|
|
this_thread::sleep_for(chrono::microseconds(20)); |
|
|
this_thread::sleep_for(chrono::microseconds(20)); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void Worker::stopWorking() |
|
|
void Worker::stopWorking() |
|
@ -90,9 +87,8 @@ void Worker::stopWorking() |
|
|
WorkerState ex = WorkerState::Started; |
|
|
WorkerState ex = WorkerState::Started; |
|
|
m_state.compare_exchange_strong(ex, WorkerState::Stopping); |
|
|
m_state.compare_exchange_strong(ex, WorkerState::Stopping); |
|
|
|
|
|
|
|
|
DEV_TIMED_ABOVE("Stop worker", 100) |
|
|
while (m_state != WorkerState::Stopped) |
|
|
while (m_state != WorkerState::Stopped) |
|
|
this_thread::sleep_for(chrono::microseconds(20)); |
|
|
this_thread::sleep_for(chrono::microseconds(20)); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -103,10 +99,7 @@ void Worker::terminate() |
|
|
if (m_work) |
|
|
if (m_work) |
|
|
{ |
|
|
{ |
|
|
m_state.exchange(WorkerState::Killing); |
|
|
m_state.exchange(WorkerState::Killing); |
|
|
|
|
|
m_work->join(); |
|
|
DEV_TIMED_ABOVE("Terminate worker", 100) |
|
|
|
|
|
m_work->join(); |
|
|
|
|
|
|
|
|
|
|
|
m_work.reset(); |
|
|
m_work.reset(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|