bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
RequestServiceTimer Class Reference

The master request service timer for this server; a singleton. More...

#include <RequestServiceTimer.h>

Collaboration diagram for RequestServiceTimer:
Collaboration graph

Public Member Functions

void disable_timeout ()
 Set the time_out is disabled.
 
std::string dump (bool pretty=false) const
 
void dump (std::ostream &strm) const
 dumps information about this object
 
std::chrono::milliseconds elapsed () const
 Return the time duration in milliseconds since the timer was started.
 
std::chrono::steady_clock::time_point get_start_time () const
 
bool is_expired () const
 if the time_out is disabled return false.
 
bool is_timeout_enabled () const
 
std::chrono::milliseconds remaining () const
 If the time_out is enabled returns the time remaining. If the time_out is disabled returns 0.
 
void start (std::chrono::milliseconds timeout_ms)
 Set/Reset the timer start_time to now().
 
void throw_if_timeout_expired (const std::string &message, const std::string &file, const int line)
 Checks the RequestServiceTimer to determine if the time spent servicing the request at this point has exceeded the bes_timeout configuration element. If the request timeout has expired throw BESInternalFatalError.
 

Static Public Member Functions

static RequestServiceTimerTheTimer ()
 Return a pointer to a singleton timer instance. If an instance does not exist it will create and initialize one. The initialization sets the start_time to now and time_out disabled.
 

Detailed Description

The master request service timer for this server; a singleton.

Definition at line 41 of file RequestServiceTimer.h.

Member Function Documentation

◆ disable_timeout()

void RequestServiceTimer::disable_timeout ( )

Set the time_out is disabled.

Definition at line 144 of file RequestServiceTimer.cc.

◆ dump() [1/2]

string RequestServiceTimer::dump ( bool pretty = false) const

Definition at line 149 of file RequestServiceTimer.cc.

◆ dump() [2/2]

void RequestServiceTimer::dump ( std::ostream & strm) const

dumps information about this object

Displays the pointer value of this instance

Parameters
strmC++ i/o stream to dump the information to

Definition at line 175 of file RequestServiceTimer.cc.

◆ elapsed()

milliseconds RequestServiceTimer::elapsed ( ) const

Return the time duration in milliseconds since the timer was started.

Definition at line 103 of file RequestServiceTimer.cc.

◆ get_start_time()

std::chrono::steady_clock::time_point RequestServiceTimer::get_start_time ( ) const
inline

Definition at line 62 of file RequestServiceTimer.h.

◆ is_expired()

bool RequestServiceTimer::is_expired ( ) const

if the time_out is disabled return false.

If the time_out is enabled return false if there is time remaining else return true; the time_out has expired.

Definition at line 134 of file RequestServiceTimer.cc.

◆ is_timeout_enabled()

bool RequestServiceTimer::is_timeout_enabled ( ) const
inline

Definition at line 68 of file RequestServiceTimer.h.

◆ remaining()

milliseconds RequestServiceTimer::remaining ( ) const

If the time_out is enabled returns the time remaining. If the time_out is disabled returns 0.

The return value is only of interest if the timeout is enabled so checking is_timeout_enabled() is an important precondition before assessing the value of remaining().

Returns

Definition at line 115 of file RequestServiceTimer.cc.

◆ start()

void RequestServiceTimer::start ( std::chrono::milliseconds timeout_ms)

Set/Reset the timer start_time to now().

Parameters
timeout_msthe time_out, in milliseconds. A timeout_ms of 0 sets timeout_disabled to true.

The RequestServiceTimer is a per request timer, the start method should be called prior to executing each request.

Definition at line 85 of file RequestServiceTimer.cc.

◆ TheTimer()

RequestServiceTimer * RequestServiceTimer::TheTimer ( )
static

Return a pointer to a singleton timer instance. If an instance does not exist it will create and initialize one. The initialization sets the start_time to now and time_out disabled.

Definition at line 59 of file RequestServiceTimer.cc.

◆ throw_if_timeout_expired()

void RequestServiceTimer::throw_if_timeout_expired ( const std::string & message,
const std::string & file,
const int line )

Checks the RequestServiceTimer to determine if the time spent servicing the request at this point has exceeded the bes_timeout configuration element. If the request timeout has expired throw BESInternalFatalError.

Parameters
messageto be delivered in error response.
fileThe file (FILE) that called this method
lineThe line (LINE) in the file that made the call to this method.

Definition at line 190 of file RequestServiceTimer.cc.


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