30 void Worker::startWorking()
37 m_state.compare_exchange_strong(ex, WorkerState::Starting);
41 m_state = WorkerState::Starting;
42 m_work.reset(
new thread([&]()
46 while (m_state != WorkerState::Killing)
49 bool ok = m_state.compare_exchange_strong(ex, WorkerState::Started);
59 catch (std::exception
const& _e)
61 clog(
WarnChannel) <<
"Exception thrown in Worker thread: " << _e.what();
67 ex = m_state.exchange(WorkerState::Stopped);
69 if (ex == WorkerState::Killing || ex == WorkerState::Starting)
74 while (m_state == WorkerState::Stopped)
75 this_thread::sleep_for(chrono::milliseconds(20));
81 while (m_state == WorkerState::Starting)
82 this_thread::sleep_for(chrono::microseconds(20));
85 void Worker::stopWorking()
91 m_state.compare_exchange_strong(ex, WorkerState::Stopping);
94 while (m_state != WorkerState::Stopped)
95 this_thread::sleep_for(chrono::microseconds(20));
99 void Worker::terminate()
105 m_state.exchange(WorkerState::Killing);
114 void Worker::workLoop()
116 while (m_state == WorkerState::Started)
119 this_thread::sleep_for(chrono::milliseconds(m_idleWaitMs));
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
std::hash for asio::adress
#define DEV_TIMED_ABOVE(S, MS)
#define DEV_GUARDED(MUTEX)
Simple block guard.
std::lock_guard< std::mutex > Guard
void setThreadName(std::string const &_n)
Set the current thread's log name.