#include <Countdown_Time.h>
Collaboration diagram for ACE_Countdown_Time:
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 Member Functions | |
ACE_Countdown_Time (const ACE_Countdown_Time &) | |
ACE_Countdown_Time & | operator= (const ACE_Countdown_Time &) |
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. |
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 37 of file Countdown_Time.h.
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Countdown_Time::ACE_Countdown_Time | ( | ACE_Time_Value * | max_wait_time | ) |
Cache the max_wait_time and call start()
.
Definition at line 10 of file Countdown_Time.cpp.
00011 : max_wait_time_ (max_wait_time), 00012 stopped_ (false) 00013 { 00014 this->start (); 00015 }
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 17 of file Countdown_Time.cpp.
References stop().
00018 { 00019 this->stop (); 00020 }
ACE_Countdown_Time::ACE_Countdown_Time | ( | const ACE_Countdown_Time & | ) | [private] |
ACE_Countdown_Time& ACE_Countdown_Time::operator= | ( | const ACE_Countdown_Time & | ) | [private] |
void ACE_Countdown_Time::start | ( | void | ) |
Cache the current time and enter a start state.
Definition at line 23 of file Countdown_Time.cpp.
References ACE_OS::gettimeofday(), start_time_, and stopped_.
Referenced by update().
00024 { 00025 if (this->max_wait_time_ != 0) 00026 { 00027 this->start_time_ = ACE_OS::gettimeofday (); 00028 this->stopped_ = false; 00029 } 00030 }
void ACE_Countdown_Time::stop | ( | void | ) |
Subtract the elapsed time from max_wait_time_ and enter a stopped state.
Definition at line 39 of file Countdown_Time.cpp.
References ACE_OS::gettimeofday(), max_wait_time_, start_time_, stopped_, and ACE_Time_Value::zero.
Referenced by update(), and ~ACE_Countdown_Time().
00040 { 00041 if (this->max_wait_time_ != 0 && this->stopped_ == false) 00042 { 00043 ACE_Time_Value elapsed_time = ACE_OS::gettimeofday () - this->start_time_; 00044 00045 if (*this->max_wait_time_ > elapsed_time) 00046 { 00047 *this->max_wait_time_ -= elapsed_time; 00048 } 00049 else 00050 { 00051 // Used all of timeout. 00052 *this->max_wait_time_ = ACE_Time_Value::zero; 00053 // errno = ETIME; 00054 } 00055 this->stopped_ = true; 00056 } 00057 }
bool ACE_Countdown_Time::stopped | ( | void | ) | const |
Returns true if we've already been stopped, else false.
Definition at line 33 of file Countdown_Time.cpp.
References stopped_.
00034 { 00035 return stopped_; 00036 }
void ACE_Countdown_Time::update | ( | void | ) |
Calls stop and then start. max_wait_time_ is modified by the call to stop.
Definition at line 60 of file Countdown_Time.cpp.
References start(), and stop().
Referenced by ACE_TP_Reactor::handle_events(), and ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_events().
ACE_Time_Value* ACE_Countdown_Time::max_wait_time_ [private] |
Maximum time we were willing to wait.
Definition at line 63 of file Countdown_Time.h.
Referenced by stop().
bool ACE_Countdown_Time::stopped_ [private] |