KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ACTIVATION_HELPER< T > Class Template Reference

A helper class to manage the activation of a "proposal" after a timeout. More...

Public Types

using ACTIVATION_CALLBACK = std::function< void(T &&)>
 

Public Member Functions

 ACTIVATION_HELPER (std::chrono::milliseconds aTimeout, ACTIVATION_CALLBACK aCallback)
 
 ~ACTIVATION_HELPER ()
 
void ProposeActivation (T &&aProposal, std::size_t aProposalTag)
 
void CancelProposal ()
 
void ProposalCheckFunction ()
 

Private Attributes

std::mutex m_mutex
 
std::chrono::milliseconds m_timeout
 
std::chrono::time_point< std::chrono::steady_clock > m_proposalDeadline
 The last proposal tag that was made.
 
std::optional< std::size_t > m_pendingProposalTag
 The last proposal that was accepted.
 
std::optional< std::size_t > m_lastAcceptedProposalTag
 
m_lastProposal
 Callback to call when the proposal is accepted.
 
ACTIVATION_CALLBACK m_callback
 
std::condition_variable m_cv
 
std::atomic< bool > m_stop
 
std::thread m_thread
 

Detailed Description

template<typename T>
class ACTIVATION_HELPER< T >

A helper class to manage the activation of a "proposal" after a timeout.

When a proposal is made, a timer starts. If no new proposal is made and the proposal is not cancelled before the timer expires, the proposal is "accepted" via a callback.

Propos

Template Parameters
TThe type of the proposal, which will be passed to the callback (by value)

Definition at line 44 of file construction_manager.cpp.

Member Typedef Documentation

◆ ACTIVATION_CALLBACK

template<typename T >
using ACTIVATION_HELPER< T >::ACTIVATION_CALLBACK = std::function<void( T&& )>

Definition at line 47 of file construction_manager.cpp.

Constructor & Destructor Documentation

◆ ACTIVATION_HELPER()

template<typename T >
ACTIVATION_HELPER< T >::ACTIVATION_HELPER ( std::chrono::milliseconds  aTimeout,
ACTIVATION_CALLBACK  aCallback 
)
inline

Definition at line 49 of file construction_manager.cpp.

◆ ~ACTIVATION_HELPER()

Member Function Documentation

◆ CancelProposal()

template<typename T >
void ACTIVATION_HELPER< T >::CancelProposal ( )
inline

◆ ProposalCheckFunction()

◆ ProposeActivation()

Member Data Documentation

◆ m_callback

template<typename T >
ACTIVATION_CALLBACK ACTIVATION_HELPER< T >::m_callback
private

◆ m_cv

◆ m_lastAcceptedProposalTag

template<typename T >
std::optional<std::size_t> ACTIVATION_HELPER< T >::m_lastAcceptedProposalTag
private

◆ m_lastProposal

template<typename T >
T ACTIVATION_HELPER< T >::m_lastProposal
private

Callback to call when the proposal is accepted.

Definition at line 158 of file construction_manager.cpp.

Referenced by ACTIVATION_HELPER< T >::ProposalCheckFunction(), and ACTIVATION_HELPER< T >::ProposeActivation().

◆ m_mutex

◆ m_pendingProposalTag

template<typename T >
std::optional<std::size_t> ACTIVATION_HELPER< T >::m_pendingProposalTag
private

◆ m_proposalDeadline

template<typename T >
std::chrono::time_point<std::chrono::steady_clock> ACTIVATION_HELPER< T >::m_proposalDeadline
private

The last proposal tag that was made.

Definition at line 149 of file construction_manager.cpp.

Referenced by ACTIVATION_HELPER< T >::ProposalCheckFunction(), and ACTIVATION_HELPER< T >::ProposeActivation().

◆ m_stop

template<typename T >
std::atomic<bool> ACTIVATION_HELPER< T >::m_stop
private

◆ m_thread

template<typename T >
std::thread ACTIVATION_HELPER< T >::m_thread
private

◆ m_timeout

template<typename T >
std::chrono::milliseconds ACTIVATION_HELPER< T >::m_timeout
private

Definition at line 147 of file construction_manager.cpp.

Referenced by ACTIVATION_HELPER< T >::ProposeActivation().


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