Bitcoin Core  0.18.99
P2P Digital Currency
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SingleThreadedSchedulerClient Class Reference

Class used by CScheduler clients which may schedule multiple jobs which are required to be run serially. More...

#include <scheduler.h>

Collaboration diagram for SingleThreadedSchedulerClient:
[legend]

Public Member Functions

 SingleThreadedSchedulerClient (CScheduler *pschedulerIn)
 
void AddToProcessQueue (std::function< void()> func)
 Add a callback to be executed. More...
 
void EmptyQueue ()
 
size_t CallbacksPending ()
 

Private Member Functions

std::list< std::function< void()> > m_callbacks_pending GUARDED_BY (m_cs_callbacks_pending)
 
bool m_are_callbacks_running GUARDED_BY (m_cs_callbacks_pending)
 
void MaybeScheduleProcessQueue ()
 
void ProcessQueue ()
 

Private Attributes

CSchedulerm_pscheduler
 
CCriticalSection m_cs_callbacks_pending
 

Detailed Description

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 97 of file scheduler.h.

Constructor & Destructor Documentation

◆ SingleThreadedSchedulerClient()

SingleThreadedSchedulerClient::SingleThreadedSchedulerClient ( CScheduler pschedulerIn)
inlineexplicit

Definition at line 109 of file scheduler.h.

Member Function Documentation

◆ AddToProcessQueue()

void SingleThreadedSchedulerClient::AddToProcessQueue ( std::function< void()>  func)

Add a callback to be executed.

Callbacks are executed serially and memory is release-acquire consistent between callback executions. Practically, this means that callbacks can behave as if they are executed in order by a single thread.

Definition at line 189 of file scheduler.cpp.

◆ CallbacksPending()

size_t SingleThreadedSchedulerClient::CallbacksPending ( )

Definition at line 209 of file scheduler.cpp.

◆ EmptyQueue()

void SingleThreadedSchedulerClient::EmptyQueue ( )

Definition at line 199 of file scheduler.cpp.

◆ GUARDED_BY() [1/2]

std::list<std::function<void ()> > m_callbacks_pending SingleThreadedSchedulerClient::GUARDED_BY ( m_cs_callbacks_pending  )
private

◆ GUARDED_BY() [2/2]

bool m_are_callbacks_running SingleThreadedSchedulerClient::GUARDED_BY ( m_cs_callbacks_pending  )
private

◆ MaybeScheduleProcessQueue()

void SingleThreadedSchedulerClient::MaybeScheduleProcessQueue ( )
private

Definition at line 148 of file scheduler.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessQueue()

void SingleThreadedSchedulerClient::ProcessQueue ( )
private

Definition at line 160 of file scheduler.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_cs_callbacks_pending

CCriticalSection SingleThreadedSchedulerClient::m_cs_callbacks_pending
private

Definition at line 101 of file scheduler.h.

◆ m_pscheduler

CScheduler* SingleThreadedSchedulerClient::m_pscheduler
private

Definition at line 99 of file scheduler.h.


The documentation for this class was generated from the following files: