Bitcoin ABC 0.26.3
P2P Digital Currency
|
Class used by CScheduler clients which may schedule multiple jobs which are required to be run serially. More...
#include <scheduler.h>
Public Member Functions | |
SingleThreadedSchedulerClient (CScheduler &scheduler LIFETIMEBOUND) | |
void | AddToProcessQueue (std::function< void()> func) EXCLUSIVE_LOCKS_REQUIRED(!m_callbacks_mutex) |
Add a callback to be executed. | |
void | EmptyQueue () EXCLUSIVE_LOCKS_REQUIRED(!m_callbacks_mutex) |
Processes all remaining queue members on the calling thread, blocking until queue is empty. | |
size_t | CallbacksPending () EXCLUSIVE_LOCKS_REQUIRED(!m_callbacks_mutex) |
Private Member Functions | |
std::list< std::function< void()> > m_callbacks_pending | GUARDED_BY (m_callbacks_mutex) |
bool m_are_callbacks_running | GUARDED_BY (m_callbacks_mutex) |
void | MaybeScheduleProcessQueue () EXCLUSIVE_LOCKS_REQUIRED(!m_callbacks_mutex) |
void | ProcessQueue () EXCLUSIVE_LOCKS_REQUIRED(!m_callbacks_mutex) |
Private Attributes | |
CScheduler & | m_scheduler |
Mutex | m_callbacks_mutex |
Class used by CScheduler clients which may schedule multiple jobs which are required to be run serially.
Jobs may not be run on the same thread, but no two jobs will be executed at the same time and memory will be release-acquire consistent (the scheduler will internally do an acquire before invoking a callback as well as a release at the end). In practice this means that a callback B() will be able to observe all of the effects of callback A() which executed before it.
Definition at line 143 of file scheduler.h.
|
inlineexplicit |
Definition at line 157 of file scheduler.h.
Add a callback to be executed.
Callbacks are executed serially and memory is release-acquire consistent between callback executions. Practially, this means that callbacks can behave as if they are executed in order by a single thread.
Definition at line 188 of file scheduler.cpp.
size_t SingleThreadedSchedulerClient::CallbacksPending | ( | ) |
void SingleThreadedSchedulerClient::EmptyQueue | ( | ) |
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!
Definition at line 197 of file scheduler.cpp.
|
private |
|
private |
|
private |
Definition at line 136 of file scheduler.cpp.
|
private |
Definition at line 153 of file scheduler.cpp.
|
private |
Definition at line 147 of file scheduler.h.
|
private |
Definition at line 145 of file scheduler.h.