There's a proper way to workaround the silliness, io_service::work

This commit is contained in:
JoelKatz
2012-09-18 13:21:07 -07:00
parent 77c06a1ca0
commit 73c5b6addb
2 changed files with 4 additions and 13 deletions

View File

@@ -35,14 +35,8 @@ DatabaseCon::~DatabaseCon()
delete mDatabase; delete mDatabase;
} }
static void resetTimer(boost::asio::deadline_timer* timer)
{ // ugly workaround for Boost IO service weirdness
timer->expires_from_now(boost::posix_time::hours(24));
timer->async_wait(boost::bind(resetTimer, timer));
}
Application::Application() : Application::Application() :
mIOTimer(mIOService), mAuxTimer(mAuxService), mUNL(mIOService), mIOWork(mIOService), mAuxWork(mAuxService), mUNL(mIOService),
mNetOps(mIOService, &mMasterLedger), mTempNodeCache(16384, 90), mHashedObjectStore(16384, 300), mNetOps(mIOService, &mMasterLedger), mTempNodeCache(16384, 90), mHashedObjectStore(16384, 300),
mSNTPClient(mAuxService), mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL), mSNTPClient(mAuxService), mRpcDB(NULL), mTxnDB(NULL), mLedgerDB(NULL), mWalletDB(NULL),
mHashNodeDB(NULL), mNetNodeDB(NULL), mHashNodeDB(NULL), mNetNodeDB(NULL),
@@ -50,9 +44,6 @@ Application::Application() :
{ {
RAND_bytes(mNonce256.begin(), mNonce256.size()); RAND_bytes(mNonce256.begin(), mNonce256.size());
RAND_bytes(reinterpret_cast<unsigned char *>(&mNonceST), sizeof(mNonceST)); RAND_bytes(reinterpret_cast<unsigned char *>(&mNonceST), sizeof(mNonceST));
resetTimer(&mIOTimer);
resetTimer(&mAuxTimer);
} }
extern const char *RpcDBInit[], *TxnDBInit[], *LedgerDBInit[], *WalletDBInit[], *HashNodeDBInit[], *NetNodeDBInit[]; extern const char *RpcDBInit[], *TxnDBInit[], *LedgerDBInit[], *WalletDBInit[], *HashNodeDBInit[], *NetNodeDBInit[];
@@ -60,10 +51,10 @@ extern int RpcDBCount, TxnDBCount, LedgerDBCount, WalletDBCount, HashNodeDBCount
void Application::stop() void Application::stop()
{ {
mAuxService.stop();
mIOService.stop(); mIOService.stop();
mHashedObjectStore.bulkWrite(); mHashedObjectStore.bulkWrite();
mValidations.flush(); mValidations.flush();
mAuxService.stop();
Log(lsINFO) << "Stopped: " << mIOService.stopped(); Log(lsINFO) << "Stopped: " << mIOService.stopped();
} }

View File

@@ -40,7 +40,7 @@ public:
class Application class Application
{ {
boost::asio::io_service mIOService, mAuxService; boost::asio::io_service mIOService, mAuxService;
boost::asio::deadline_timer mIOTimer, mAuxTimer; boost::asio::io_service::work mIOWork, mAuxWork;
Wallet mWallet; Wallet mWallet;
UniqueNodeList mUNL; UniqueNodeList mUNL;