KiCad PCB EDA Suite
|
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) | |
void | ProposeActivation (T &&aProposal, std::size_t aProposalTag, bool aAcceptImmediately) |
void | CancelProposal () |
Private Member Functions | |
void | onTimerExpiry (wxTimerEvent &aEvent) |
Timer expiry callback in the UI thread. | |
void | acceptPendingProposal () |
Private Attributes | |
std::mutex | m_mutex |
std::chrono::milliseconds | m_timeout |
Activation timeout in milliseconds. | |
std::optional< std::size_t > | m_pendingProposalTag |
The last proposal tag that was made. | |
std::optional< std::size_t > | m_lastAcceptedProposalTag |
The last proposal that was accepted. | |
T | m_lastProposal |
The most recently-proposed item. | |
ACTIVATION_CALLBACK | m_callback |
Callback to call when the proposal is accepted. | |
wxTimer | m_timer |
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 canceled before the timer expires, the proposal is "accepted" via a callback.
Proposals are "tagged" with a hash - this is used to avoid reproposing the same thing multiple times.
T | The type of the proposal, which will be passed to the callback (by value) |
Definition at line 46 of file construction_manager.cpp.
using ACTIVATION_HELPER< T >::ACTIVATION_CALLBACK = std::function<void( T&& )> |
Definition at line 49 of file construction_manager.cpp.
|
inline |
Definition at line 51 of file construction_manager.cpp.
References ACTIVATION_HELPER< T >::m_timer, and ACTIVATION_HELPER< T >::onTimerExpiry().
|
inlineprivate |
Definition at line 106 of file construction_manager.cpp.
References ACTIVATION_HELPER< T >::m_callback, ACTIVATION_HELPER< T >::m_lastAcceptedProposalTag, ACTIVATION_HELPER< T >::m_lastProposal, ACTIVATION_HELPER< T >::m_mutex, and ACTIVATION_HELPER< T >::m_pendingProposalTag.
Referenced by ACTIVATION_HELPER< T >::onTimerExpiry(), and ACTIVATION_HELPER< T >::ProposeActivation().
|
inline |
Definition at line 90 of file construction_manager.cpp.
References ACTIVATION_HELPER< T >::m_mutex, ACTIVATION_HELPER< T >::m_pendingProposalTag, and ACTIVATION_HELPER< T >::m_timer.
|
inlineprivate |
Timer expiry callback in the UI thread.
Definition at line 101 of file construction_manager.cpp.
References ACTIVATION_HELPER< T >::acceptPendingProposal().
Referenced by ACTIVATION_HELPER< T >::ACTIVATION_HELPER().
|
inline |
Definition at line 58 of file construction_manager.cpp.
References ACTIVATION_HELPER< T >::acceptPendingProposal(), ACTIVATION_HELPER< T >::m_lastAcceptedProposalTag, ACTIVATION_HELPER< T >::m_lastProposal, ACTIVATION_HELPER< T >::m_mutex, ACTIVATION_HELPER< T >::m_pendingProposalTag, ACTIVATION_HELPER< T >::m_timeout, and ACTIVATION_HELPER< T >::m_timer.
|
private |
Callback to call when the proposal is accepted.
Definition at line 140 of file construction_manager.cpp.
Referenced by ACTIVATION_HELPER< T >::acceptPendingProposal().
|
private |
The last proposal that was accepted.
Definition at line 134 of file construction_manager.cpp.
Referenced by ACTIVATION_HELPER< T >::acceptPendingProposal(), and ACTIVATION_HELPER< T >::ProposeActivation().
|
private |
The most recently-proposed item.
Definition at line 137 of file construction_manager.cpp.
Referenced by ACTIVATION_HELPER< T >::acceptPendingProposal(), and ACTIVATION_HELPER< T >::ProposeActivation().
|
mutableprivate |
Definition at line 125 of file construction_manager.cpp.
Referenced by ACTIVATION_HELPER< T >::acceptPendingProposal(), ACTIVATION_HELPER< T >::CancelProposal(), and ACTIVATION_HELPER< T >::ProposeActivation().
|
private |
The last proposal tag that was made.
Definition at line 131 of file construction_manager.cpp.
Referenced by ACTIVATION_HELPER< T >::acceptPendingProposal(), ACTIVATION_HELPER< T >::CancelProposal(), and ACTIVATION_HELPER< T >::ProposeActivation().
|
private |
Activation timeout in milliseconds.
Definition at line 128 of file construction_manager.cpp.
Referenced by ACTIVATION_HELPER< T >::ProposeActivation().
|
private |
Definition at line 142 of file construction_manager.cpp.
Referenced by ACTIVATION_HELPER< T >::ACTIVATION_HELPER(), ACTIVATION_HELPER< T >::CancelProposal(), and ACTIVATION_HELPER< T >::ProposeActivation().