diff --git a/libethereum/Client.cpp b/libethereum/Client.cpp index 46da3e1f7..cc579ec08 100644 --- a/libethereum/Client.cpp +++ b/libethereum/Client.cpp @@ -571,19 +571,13 @@ void Client::doWork() { // TODO: Use condition variable rather than this rubbish. - Guard l(x_fakeSignalSystemState); - - if (m_syncTransactionQueue) - { - m_syncTransactionQueue = false; + bool t = true; + if (m_syncTransactionQueue.compare_exchange_strong(t, false)) syncTransactionQueue(); - } - if (m_syncBlockQueue) - { - m_syncBlockQueue = false; + t = true; + if (m_syncBlockQueue.compare_exchange_strong(t, false)) syncBlockQueue(); - } checkWatchGarbage(); diff --git a/libethereum/Client.h b/libethereum/Client.h index 16033a11f..289df3fe0 100644 --- a/libethereum/Client.h +++ b/libethereum/Client.h @@ -249,10 +249,10 @@ private: void syncTransactionQueue(); /// Magically called when m_tq needs syncing. Be nice and don't block. - void onTransactionQueueReady() { Guard l(x_fakeSignalSystemState); m_syncTransactionQueue = true; } + void onTransactionQueueReady() { m_syncTransactionQueue = true; } /// Magically called when m_tq needs syncing. Be nice and don't block. - void onBlockQueueReady() { Guard l(x_fakeSignalSystemState); m_syncBlockQueue = true; } + void onBlockQueueReady() { m_syncBlockQueue = true; } /// Called when the post state has changed (i.e. when more transactions are in it or we're mining on a new block). /// This updates m_miningInfo. @@ -286,9 +286,8 @@ private: ///< When did we last both doing GC on the watches? // TODO!!!!!! REPLACE WITH A PROPER X-THREAD ASIO SIGNAL SYSTEM (could just be condition variables) - mutable Mutex x_fakeSignalSystemState; - bool m_syncTransactionQueue = false; - bool m_syncBlockQueue = false; + std::atomic m_syncTransactionQueue = {false}; + std::atomic m_syncBlockQueue = {false}; }; }