Timeout Class Reference

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

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

List of all members.

Classes

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

Public Member Functions

 Timeout (int max_tmos=100)
 Construct a Timeout object.
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.
void add_periodic (const char *desc, void *tag, std::function< void()> &function, int rel_ms)
 Add a periodic timeout to the Timeout container.
void add_periodic (const char *desc, uint64_t period_us, uint64_t start_us=0)
 Add a periodic timeout to the Timeout container.
void add_relative (const char *desc, void *tag, std::function< void()> &function, int rel_ms)
 Add a periodic timeout to the Timeout container.
void add_relative (std::string desc, int rel_ms)
 Add a periodic timeout to the Timeout container.
void copy_in_timeout (const char *desc, uint64_t period_us, uint64_t start_us=0)
 Add a timeout with the given parameters.
bool cancel_timeout (void *tag, std::string desc)
 Cancel the timeout having the given description and tag.
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.
void get_next_timeout_delay (int64_t *delay_us)
 Get the amount to wait for the next timeout to occur.
int get_next_timeout_msdly ()
 Get the amount to wait for the next timeout to occur.
uint64_t gettimeofday_us ()
 Get the current time of day in microseconds (from gettimeofday system call).
bool is_consistent ()
 Run a consistency check on all confiugured timeouts.
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_tmos Maximum number of registered Timeout functions

Definition at line 51 of file Timeout.cc.


Member Function Documentation

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:
desc Description of the periodic timeout
period_us Period for timeouts
start_us When to start (defaults to 0)

maybe need to return a timeout id??

Definition at line 89 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:
desc Description of the periodic timeout
tag Tag (fd or other) to apply to timeout
function Function to execute at timeout
rel_ms Timeout in rem_ms milliseconds

maybe need to return a timeout id??

Definition at line 75 of file Timeout.cc.

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:
desc Description of the periodic timeout
tag Tag (fd or other) to apply to timeout
function Function to execute at timeout
period_us Period for timeouts
start_us When to start (defaults to 0)

maybe need to return a timeout id??

Definition at line 60 of file Timeout.cc.

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

Add a periodic timeout to the Timeout container.

Parameters:
desc Description of the periodic timeout
rel_ms Timeout in rem_ms milliseconds

maybe need to return a timeout id??

Definition at line 120 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:
desc Description of the periodic timeout
tag Tag (fd or other) to apply to timeout
function Function to execute at timeout
rel_ms Timeout in rem_ms milliseconds

maybe need to return a timeout id??

Definition at line 106 of file Timeout.cc.

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

Cancel the timeout having the given description and tag.

Parameters:
tag Tag of the cancelled timeout
desc Description of the cancelled timeout
Returns:
Whether a timeout was found and cancelled

Definition at line 328 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:
desc Description of new timeout
period_us Period that the timeout should execute with
start_us When to start the timeout (default 0)

Definition at line 298 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] desc Description of timeout that expired
[out] tag Tag of timeout that expired
[out] function Function of timeout that expired
[out] tmo_tod_us When the timeout expired
Returns:
-1 if no timeouts expired

Definition at line 134 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_us Microseconds until next timeout

Definition at line 157 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 178 of file Timeout.cc.

uint64_t Timeout::gettimeofday_us (  ) 

Get the current time of day in microseconds (from gettimeofday system call).

Returns:
The current time of day in microseconds

Definition at line 211 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 196 of file Timeout.cc.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator

Generated on 16 Aug 2017 for artdaq by  doxygen 1.6.1