From 90960ec07f2e4cfa30f19f51c7e09b739011511a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sat, 18 Aug 2018 14:35:58 +0300 Subject: [PATCH] Make Worker::run(mxb::Semaphore*) private The semaphore is only used when Worker::start() is called to synchronize the startup of the two threads. Also asserted that the state is what we expected it to be. --- include/maxscale/worker.hh | 9 ++++++--- server/core/worker.cc | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/maxscale/worker.hh b/include/maxscale/worker.hh index de5801607..d6fc21bcb 100644 --- a/include/maxscale/worker.hh +++ b/include/maxscale/worker.hh @@ -672,10 +672,11 @@ public: * The worker will run the poll loop, until it is told to shut down. * * @attention This function will run in the calling thread. - * - * @param pSem Semaphore that is posted on once the thread has started */ - void run(mxb::Semaphore* pSem = NULL); + void run() + { + run(nullptr); + } /** * Run worker in separate thread. @@ -1195,6 +1196,8 @@ private: } }; + void run(mxb::Semaphore* pSem); + typedef DelegatingTimer PrivateTimer; typedef std::multimap DelayedCallsByTime; typedef std::unordered_map DelayedCallsById; diff --git a/server/core/worker.cc b/server/core/worker.cc index 3fb008040..ef18299c2 100644 --- a/server/core/worker.cc +++ b/server/core/worker.cc @@ -529,6 +529,7 @@ bool Worker::post_message(uint32_t msg_id, intptr_t arg1, intptr_t arg2) void Worker::run(mxb::Semaphore* pSem) { + ss_dassert(m_state == STOPPED); this_thread.pCurrent_worker = this; if (pre_run())