Browse Source

Marginally better Client async code.

cl-refactor
Gav Wood 10 years ago
parent
commit
1b05e078e4
  1. 14
      libethereum/Client.cpp
  2. 9
      libethereum/Client.h

14
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();

9
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<bool> m_syncTransactionQueue = {false};
std::atomic<bool> m_syncBlockQueue = {false};
};
}

Loading…
Cancel
Save