From 735d9b5362aeca34c0e62006986fe9d82c24ca08 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Wed, 8 Feb 2017 13:19:18 -0500 Subject: Use CScheduler for wallet flushing, remove ThreadFlushWalletDB --- src/wallet/wallet.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/wallet/wallet.cpp') 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 CWallet::fFlushThreadRunning(false); +std::atomic 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); } } -- cgit v1.2.3