diff options
author | Matt Corallo <git@bluematt.me> | 2017-02-08 13:19:18 -0500 |
---|---|---|
committer | Matt Corallo <git@bluematt.me> | 2017-03-06 18:35:19 -0500 |
commit | 735d9b5362aeca34c0e62006986fe9d82c24ca08 (patch) | |
tree | 25e2a8ba6b29162ba94520e67f60b9f805e51f7d /src/wallet/wallet.cpp | |
parent | 73296f54d6f0b38fcac627882d2e9480a2bad14a (diff) | |
download | bitcoin-735d9b5362aeca34c0e62006986fe9d82c24ca08.tar.xz |
Use CScheduler for wallet flushing, remove ThreadFlushWalletDB
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r-- | src/wallet/wallet.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 02af1bf10f..88dbb77ab5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -20,6 +20,7 @@ #include "primitives/transaction.h" #include "script/script.h" #include "script/sign.h" +#include "scheduler.h" #include "timedata.h" #include "txmempool.h" #include "util.h" @@ -3754,17 +3755,17 @@ bool CWallet::InitLoadWallet() return true; } -std::atomic<bool> CWallet::fFlushThreadRunning(false); +std::atomic<bool> CWallet::fFlushScheduled(false); -void CWallet::postInitProcess(boost::thread_group& threadGroup) +void CWallet::postInitProcess(CScheduler& scheduler) { // Add wallet transactions that aren't already in a block to mempool // Do this here as mempool requires genesis block to be loaded ReacceptWalletTransactions(); // Run a thread to flush wallet periodically - if (!CWallet::fFlushThreadRunning.exchange(true)) { - threadGroup.create_thread(ThreadFlushWalletDB); + if (!CWallet::fFlushScheduled.exchange(true)) { + scheduler.scheduleEvery(MaybeFlushWalletDB, 500); } } |