From 5a933cefcc5e0595a1ec46fc5ea287aa163ecd3f Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 4 Dec 2017 18:31:36 -0500 Subject: [PATCH] Add an interface to get the queue depth out of CValidationInterface --- src/scheduler.cpp | 5 +++++ src/scheduler.h | 2 ++ src/validationinterface.cpp | 5 +++++ src/validationinterface.h | 2 ++ 4 files changed, 14 insertions(+) diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 260f6fa60e..7d5ec14610 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -206,3 +206,8 @@ void SingleThreadedSchedulerClient::EmptyQueue() { should_continue = !m_callbacks_pending.empty(); } } + +size_t SingleThreadedSchedulerClient::CallbacksPending() { + LOCK(m_cs_callbacks_pending); + return m_callbacks_pending.size(); +} diff --git a/src/scheduler.h b/src/scheduler.h index b99f165343..39ecb849b9 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -108,6 +108,8 @@ public: // Processes all remaining queue members on the calling thread, blocking until queue is empty // Must be called after the CScheduler has no remaining processing threads! void EmptyQueue(); + + size_t CallbacksPending(); }; #endif diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index abbd8cc4d2..1ddff4b335 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -54,6 +54,11 @@ void CMainSignals::FlushBackgroundCallbacks() { } } +size_t CMainSignals::CallbacksPending() { + if (!m_internals) return 0; + return m_internals->m_schedulerClient.CallbacksPending(); +} + void CMainSignals::RegisterWithMempoolSignals(CTxMemPool& pool) { pool.NotifyEntryRemoved.connect(boost::bind(&CMainSignals::MempoolEntryRemoved, this, _1, _2)); } diff --git a/src/validationinterface.h b/src/validationinterface.h index 7b5d138414..164059e3b9 100644 --- a/src/validationinterface.h +++ b/src/validationinterface.h @@ -131,6 +131,8 @@ public: /** Call any remaining callbacks on the calling thread */ void FlushBackgroundCallbacks(); + size_t CallbacksPending(); + /** Register with mempool to call TransactionRemovedFromMempool callbacks */ void RegisterWithMempoolSignals(CTxMemPool& pool); /** Unregister with mempool */