Skip to content

Commit 0c68e2f

Browse files
TheBlueMattfurszy
authored andcommitted
Add an interface to get the queue depth out of CValidationInterface
1 parent 31c7974 commit 0c68e2f

File tree

4 files changed

+14
-0
lines changed

4 files changed

+14
-0
lines changed

src/scheduler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,8 @@ void SingleThreadedSchedulerClient::EmptyQueue() {
186186
should_continue = !m_callbacks_pending.empty();
187187
}
188188
}
189+
190+
size_t SingleThreadedSchedulerClient::CallbacksPending() {
191+
LOCK(m_cs_callbacks_pending);
192+
return m_callbacks_pending.size();
193+
}

src/scheduler.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ class SingleThreadedSchedulerClient {
109109
// Processes all remaining queue members on the calling thread, blocking until queue is empty
110110
// Must be called after the CScheduler has no remaining processing threads!
111111
void EmptyQueue();
112+
113+
size_t CallbacksPending();
112114
};
113115

114116
#endif

src/validationinterface.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ void CMainSignals::FlushBackgroundCallbacks() {
7272
}
7373
}
7474

75+
size_t CMainSignals::CallbacksPending() {
76+
if (!m_internals) return 0;
77+
return m_internals->m_schedulerClient.CallbacksPending();
78+
}
79+
7580
void CMainSignals::RegisterWithMempoolSignals(CTxMemPool& pool) {
7681
pool.NotifyEntryRemoved.connect(std::bind(&CMainSignals::MempoolEntryRemoved, this, std::placeholders::_1, std::placeholders::_2));
7782
}

src/validationinterface.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ class CMainSignals {
118118
/** Call any remaining callbacks on the calling thread */
119119
void FlushBackgroundCallbacks();
120120

121+
size_t CallbacksPending();
122+
121123
/** Register with mempool to call TransactionRemovedFromMempool callbacks */
122124
void RegisterWithMempoolSignals(CTxMemPool& pool);
123125
/** Unregister with mempool */

0 commit comments

Comments
 (0)