MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::thread::BeforeOption< Clock, Duration, Callback > Struct Template Reference

Option to add a timeout on select to ensure a path runs before a timeout If the timeout is hit, a timeout error will be returned from the select Will call a callback on timeout. More...

#include <select.hpp>

Public Member Functions

Result< void, SelectOptionErrorsattempt ()
 
bool prevents_deadlock () const noexcept
 

Public Attributes

std::chrono::time_point< Clock, Duration > time_point
 
Callback callback
 

Detailed Description

template<typename Clock, typename Duration, typename Callback>
struct mtcore::thread::BeforeOption< Clock, Duration, Callback >

Option to add a timeout on select to ensure a path runs before a timeout If the timeout is hit, a timeout error will be returned from the select Will call a callback on timeout.

Template Parameters
ClockClock to get time from
DurationDuration for time point
CallbackCallback to call on timeout

Definition at line 180 of file select.hpp.

Member Function Documentation

◆ attempt()

template<typename Clock, typename Duration, typename Callback>
Result< void, SelectOptionErrors > mtcore::thread::BeforeOption< Clock, Duration, Callback >::attempt ( )
inline

Definition at line 184 of file select.hpp.

184 {
185 if (time_point <= Clock::now()) {
186 callback();
188 }
190 }
Error< Underlying > error(Underlying err)
Creates an error.
Definition result.hpp:425
Option to add a timeout on select to ensure a path runs before a timeout If the timeout is hit,...
Definition select.hpp:180
std::chrono::time_point< Clock, Duration > time_point
Definition select.hpp:181
Here is the call graph for this function:

◆ prevents_deadlock()

template<typename Clock, typename Duration, typename Callback>
bool mtcore::thread::BeforeOption< Clock, Duration, Callback >::prevents_deadlock ( ) const
inlinenodiscardnoexcept

Definition at line 193 of file select.hpp.

193{ return false; }

Member Data Documentation

◆ callback

template<typename Clock, typename Duration, typename Callback>
Callback mtcore::thread::BeforeOption< Clock, Duration, Callback >::callback

Definition at line 182 of file select.hpp.

◆ time_point

template<typename Clock, typename Duration, typename Callback>
std::chrono::time_point<Clock, Duration> mtcore::thread::BeforeOption< Clock, Duration, Callback >::time_point

Definition at line 181 of file select.hpp.


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