artdaq  v3_04_00
Timeout Class Reference

The Timeout class performs registered actions at specified intervals. More...

#include <artdaq/TransferPlugins/detail/Timeout.hh>

Classes

struct  timeoutspec
 Specification for a Timeout function. More...
 

Public Member Functions

 Timeout (int max_tmos=100)
 Construct a Timeout object. More...
 
void add_periodic (const char *desc, void *tag, std::function< void()> &function, uint64_t period_us, uint64_t start_us=0)
 Add a periodic timeout to the Timeout container. More...
 
void add_periodic (const char *desc, void *tag, std::function< void()> &function, int rel_ms)
 Add a periodic timeout to the Timeout container. More...
 
void add_periodic (const char *desc, uint64_t period_us, uint64_t start_us=0)
 Add a periodic timeout to the Timeout container. More...
 
void add_relative (const char *desc, void *tag, std::function< void()> &function, int rel_ms)
 Add a periodic timeout to the Timeout container. More...
 
void add_relative (std::string desc, int rel_ms)
 Add a periodic timeout to the Timeout container. More...
 
void copy_in_timeout (const char *desc, uint64_t period_us, uint64_t start_us=0)
 Add a timeout with the given parameters. More...
 
bool cancel_timeout (void *tag, std::string desc)
 Cancel the timeout having the given description and tag. More...
 
int get_next_expired_timeout (std::string &desc, void **tag, std::function< void()> &function, uint64_t *tmo_tod_us)
 Get a timeout that has expired. More...
 
void get_next_timeout_delay (int64_t *delay_us)
 Get the amount to wait for the next timeout to occur. More...
 
int get_next_timeout_msdly ()
 Get the amount to wait for the next timeout to occur. More...
 
bool is_consistent ()
 Run a consistency check on all confiugured timeouts. More...
 
void list_active_time ()
 TRACE all active timeouts.
 

Detailed Description

The Timeout class performs registered actions at specified intervals.

Definition at line 22 of file Timeout.hh.

Constructor & Destructor Documentation

Timeout::Timeout ( int  max_tmos = 100)
explicit

Construct a Timeout object.

Parameters
max_tmosMaximum number of registered Timeout functions

Definition at line 58 of file Timeout.cc.

Member Function Documentation

void Timeout::add_periodic ( const char *  desc,
void *  tag,
std::function< void()> &  function,
uint64_t  period_us,
uint64_t  start_us = 0 
)

Add a periodic timeout to the Timeout container.

Parameters
descDescription of the periodic timeout
tagTag (fd or other) to apply to timeout
functionFunction to execute at timeout
period_usPeriod for timeouts
start_usWhen to start (defaults to 0)

maybe need to return a timeout id??

Definition at line 67 of file Timeout.cc.

void Timeout::add_periodic ( const char *  desc,
void *  tag,
std::function< void()> &  function,
int  rel_ms 
)

Add a periodic timeout to the Timeout container.

Parameters
descDescription of the periodic timeout
tagTag (fd or other) to apply to timeout
functionFunction to execute at timeout
rel_msTimeout in rem_ms milliseconds

maybe need to return a timeout id??

Definition at line 82 of file Timeout.cc.

void Timeout::add_periodic ( const char *  desc,
uint64_t  period_us,
uint64_t  start_us = 0 
)

Add a periodic timeout to the Timeout container.

Parameters
descDescription of the periodic timeout
period_usPeriod for timeouts
start_usWhen to start (defaults to 0)

maybe need to return a timeout id??

Definition at line 96 of file Timeout.cc.

void Timeout::add_relative ( const char *  desc,
void *  tag,
std::function< void()> &  function,
int  rel_ms 
)

Add a periodic timeout to the Timeout container.

Parameters
descDescription of the periodic timeout
tagTag (fd or other) to apply to timeout
functionFunction to execute at timeout
rel_msTimeout in rem_ms milliseconds

maybe need to return a timeout id??

Definition at line 112 of file Timeout.cc.

void Timeout::add_relative ( std::string  desc,
int  rel_ms 
)

Add a periodic timeout to the Timeout container.

Parameters
descDescription of the periodic timeout
rel_msTimeout in rem_ms milliseconds

maybe need to return a timeout id??

Definition at line 126 of file Timeout.cc.

bool Timeout::cancel_timeout ( void *  tag,
std::string  desc 
)

Cancel the timeout having the given description and tag.

Parameters
tagTag of the cancelled timeout
descDescription of the cancelled timeout
Returns
Whether a timeout was found and cancelled

Definition at line 323 of file Timeout.cc.

void Timeout::copy_in_timeout ( const char *  desc,
uint64_t  period_us,
uint64_t  start_us = 0 
)

Add a timeout with the given parameters.

Parameters
descDescription of new timeout
period_usPeriod that the timeout should execute with
start_usWhen to start the timeout (default 0)

Definition at line 293 of file Timeout.cc.

int Timeout::get_next_expired_timeout ( std::string &  desc,
void **  tag,
std::function< void()> &  function,
uint64_t *  tmo_tod_us 
)

Get a timeout that has expired.

Parameters
[out]descDescription of timeout that expired
[out]tagTag of timeout that expired
[out]functionFunction of timeout that expired
[out]tmo_tod_usWhen the timeout expired
Returns
-1 if no timeouts expired

Definition at line 140 of file Timeout.cc.

void Timeout::get_next_timeout_delay ( int64_t *  delay_us)

Get the amount to wait for the next timeout to occur.

Parameters
[out]delay_usMicroseconds until next timeout

Definition at line 163 of file Timeout.cc.

int Timeout::get_next_timeout_msdly ( )

Get the amount to wait for the next timeout to occur.

Returns
Milliseconds until next timeout

Definition at line 184 of file Timeout.cc.

bool Timeout::is_consistent ( )

Run a consistency check on all confiugured timeouts.

Returns
True if all timeouts pass check

Definition at line 202 of file Timeout.cc.


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