Bitcoin Core 28.99.0
P2P Digital Currency
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
ValidationSignalsImpl Class Reference

ValidationSignalsImpl manages a list of shared_ptr<CValidationInterface> callbacks. More...

Collaboration diagram for ValidationSignalsImpl:
[legend]

Classes

struct  ListEntry
 List entries consist of a callback pointer and reference count. More...
 

Public Member Functions

 ValidationSignalsImpl (std::unique_ptr< util::TaskRunnerInterface > task_runner)
 
void Register (std::shared_ptr< CValidationInterface > callbacks) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 
void Unregister (CValidationInterface *callbacks) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 
void Clear () EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 Clear unregisters every previously registered callback, erasing every map entry. More...
 
template<typename F >
void Iterate (F &&f) EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
 

Public Attributes

std::unique_ptr< util::TaskRunnerInterfacem_task_runner
 

Private Member Functions

std::list< ListEntry > m_list GUARDED_BY (m_mutex)
 
std::unordered_map< CValidationInterface *, std::list< ListEntry >::iterator > m_map GUARDED_BY (m_mutex)
 

Private Attributes

Mutex m_mutex
 

Detailed Description

ValidationSignalsImpl manages a list of shared_ptr<CValidationInterface> callbacks.

A std::unordered_map is used to track what callbacks are currently registered, and a std::list is used to store the callbacks that are currently registered as well as any callbacks that are just unregistered and about to be deleted when they are done executing.

Definition at line 31 of file validationinterface.cpp.

Constructor & Destructor Documentation

◆ ValidationSignalsImpl()

ValidationSignalsImpl::ValidationSignalsImpl ( std::unique_ptr< util::TaskRunnerInterface task_runner)
inlineexplicit

Definition at line 46 of file validationinterface.cpp.

Member Function Documentation

◆ Clear()

void ValidationSignalsImpl::Clear ( )
inline

Clear unregisters every previously registered callback, erasing every map entry.

After this call, the list may still contain callbacks that are currently executing, but it will be cleared when they are done executing.

Definition at line 71 of file validationinterface.cpp.

◆ GUARDED_BY() [1/2]

std::list< ListEntry > m_list ValidationSignalsImpl::GUARDED_BY ( m_mutex  )
private

◆ GUARDED_BY() [2/2]

std::unordered_map< CValidationInterface *, std::list< ListEntry >::iterator > m_map ValidationSignalsImpl::GUARDED_BY ( m_mutex  )
private

◆ Iterate()

template<typename F >
void ValidationSignalsImpl::Iterate ( F &&  f)
inline

Definition at line 80 of file validationinterface.cpp.

◆ Register()

void ValidationSignalsImpl::Register ( std::shared_ptr< CValidationInterface callbacks)
inline

Definition at line 49 of file validationinterface.cpp.

◆ Unregister()

void ValidationSignalsImpl::Unregister ( CValidationInterface callbacks)
inline

Definition at line 57 of file validationinterface.cpp.

Member Data Documentation

◆ m_mutex

Mutex ValidationSignalsImpl::m_mutex
private

Definition at line 34 of file validationinterface.cpp.

◆ m_task_runner

std::unique_ptr<util::TaskRunnerInterface> ValidationSignalsImpl::m_task_runner

Definition at line 44 of file validationinterface.cpp.


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