Keeps track of the amount of elapsed time. More...
#include <Countdown_Time.h>
Public Member Functions | |
ACE_Countdown_Time (ACE_Time_Value *max_wait_time) | |
Cache the max_wait_time and call start() . | |
~ACE_Countdown_Time (void) | |
void | start (void) |
Cache the current time and enter a start state. | |
void | stop (void) |
void | update (void) |
bool | stopped (void) const |
Returns true if we've already been stopped, else false. | |
Private Attributes | |
ACE_Time_Value * | max_wait_time_ |
Maximum time we were willing to wait. | |
ACE_Time_Value | start_time_ |
Beginning of the start time. | |
bool | stopped_ |
Keeps track of whether we've already been stopped. |
Keeps track of the amount of elapsed time.
This class has a side-effect on the max_wait_time
-- every time the stop() method is called the max_wait_time
is updated.
Definition at line 38 of file Countdown_Time.h.
ACE_Countdown_Time::ACE_Countdown_Time | ( | ACE_Time_Value * | max_wait_time | ) |
Cache the max_wait_time and call start()
.
ACE_Countdown_Time::~ACE_Countdown_Time | ( | void | ) |
Destructor, makes sure the max_wait_time that got passed as pointer to the constructor is updated with the time elapsed.
Definition at line 21 of file Countdown_Time.cpp.
{ this->stop (); }
void ACE_Countdown_Time::start | ( | void | ) |
Cache the current time and enter a start state.
Definition at line 27 of file Countdown_Time.cpp.
{ if (this->max_wait_time_ != 0) { this->start_time_ = ACE_OS::gettimeofday (); this->stopped_ = false; } }
void ACE_Countdown_Time::stop | ( | void | ) |
Subtract the elapsed time from max_wait_time_ and enter a stopped state.
Definition at line 37 of file Countdown_Time.cpp.
{ if (this->max_wait_time_ != 0 && !this->stopped_) { ACE_Time_Value const elapsed_time = ACE_OS::gettimeofday () - this->start_time_; if (elapsed_time >= ACE_Time_Value::zero && *this->max_wait_time_ > elapsed_time) { *this->max_wait_time_ -= elapsed_time; } else { // Used all of timeout. *this->max_wait_time_ = ACE_Time_Value::zero; // errno = ETIME; } this->stopped_ = true; } }
bool ACE_Countdown_Time::stopped | ( | void | ) | const [inline] |
Returns true if we've already been stopped, else false.
Definition at line 8 of file Countdown_Time.inl.
{ return stopped_; }
void ACE_Countdown_Time::update | ( | void | ) | [inline] |
Calls stop and then start. max_wait_time_ is modified by the call to stop.
Definition at line 14 of file Countdown_Time.inl.
ACE_Time_Value* ACE_Countdown_Time::max_wait_time_ [private] |
Maximum time we were willing to wait.
Definition at line 64 of file Countdown_Time.h.
Beginning of the start time.
Definition at line 67 of file Countdown_Time.h.
bool ACE_Countdown_Time::stopped_ [private] |
Keeps track of whether we've already been stopped.
Definition at line 70 of file Countdown_Time.h.