Taskolib  1.3.3
Public Member Functions | Private Attributes | List of all members
task::TimeoutTrigger Class Reference

Detailed Description

Evaluates when the clock is elapsed.

TimeoutTrigger trigger;
trigger.set_timeout(1s);
while(true)
{
if(trigger.is_elapsed()) break;
// do some stuff
}
Note
This class is not thread-safe. To make it thread-safe you have to add a mutex to synchronize resources with multiple threads.

#include <TimeoutTrigger.h>

Public Member Functions

TimePoint reset ()
 Reset the timeout start time to the current time. More...
 
const Timeout get_timeout () const
 Get the timeout duration. More...
 
void set_timeout (Timeout timeout)
 Set the timeout duration. More...
 
TimePoint get_start_time () const
 Get start time. More...
 
bool is_elapsed () const
 Evaluates if a timeout elapsed. More...
 

Private Attributes

Timeout timeout_ {Timeout::infinity()}
 Timeout. More...
 
TimePoint start_ {}
 Starting clock time used to measure the elapsed time. More...
 

Member Function Documentation

◆ get_start_time()

TimePoint task::TimeoutTrigger::get_start_time ( ) const
inline

Get start time.

Returns
start time of the clock.
See also
reset()

References start_.

Referenced by task::Sequence::get_time_of_last_execution().

◆ get_timeout()

const Timeout task::TimeoutTrigger::get_timeout ( ) const
inline

Get the timeout duration.

Returns
constant timeout.

References timeout_.

Referenced by task::Sequence::get_timeout().

◆ is_elapsed()

bool task::TimeoutTrigger::is_elapsed ( ) const
inline

Evaluates if a timeout elapsed.

Returns
true when the time elapsed.
false when still accurate and in the time interval.
See also
reset()

References start_, and timeout_.

Referenced by task::Sequence::is_timeout_elapsed().

◆ reset()

TimePoint task::TimeoutTrigger::reset ( )
inline

Reset the timeout start time to the current time.

The timeout duration remains unchanged.

Returns
the new created start time for checking on elapsed timeout.

References start_.

Referenced by task::Sequence::execute().

◆ set_timeout()

void task::TimeoutTrigger::set_timeout ( Timeout  timeout)
inline

Set the timeout duration.

Parameters
timeoutto be measure with the is_elapsed() member function.

References timeout_.

Member Data Documentation

◆ start_

TimePoint task::TimeoutTrigger::start_ {}
private

Starting clock time used to measure the elapsed time.

Referenced by get_start_time(), is_elapsed(), and reset().

◆ timeout_

Timeout task::TimeoutTrigger::timeout_ {Timeout::infinity()}
private

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