ACE_Countdown_Time Class Reference

Keeps track of the amount of elapsed time. More...

#include <Countdown_Time.h>

Collaboration diagram for ACE_Countdown_Time:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Countdown_Time (ACE_Time_Value *max_wait_time)
 Cache the and call .

 ~ACE_Countdown_Time (void)
 Call .

int start (void)
 Cache the current time and enter a start state.

int stop (void)
int update (void)
int stopped (void) const
 Returns 1 if we've already been stopped, else 0.


Private Member Functions

 ACE_Countdown_Time (const ACE_Countdown_Time &)
ACE_Countdown_Timeoperator= (const ACE_Countdown_Time &)

Private Attributes

ACE_Time_Valuemax_wait_time_
 Maximum time we were willing to wait.

ACE_Time_Value start_time_
 Beginning of the start time.

int stopped_
 Keeps track of whether we've already been stopped.


Detailed Description

Keeps track of the amount of elapsed time.

This class has a side-effect on the -- every time the method is called the is updated.

Definition at line 37 of file Countdown_Time.h.


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Countdown_Time::ACE_Countdown_Time ACE_Time_Value max_wait_time  ) 
 

Cache the and call .

Definition at line 10 of file Countdown_Time.cpp.

References start().

00011   : max_wait_time_ (max_wait_time),
00012     stopped_ (0)
00013 {
00014   this->start ();
00015 }

ACE_Countdown_Time::~ACE_Countdown_Time void   ) 
 

Call .

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]
 


Member Function Documentation

ACE_Countdown_Time& ACE_Countdown_Time::operator= const ACE_Countdown_Time  )  [private]
 

int 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(), max_wait_time_, start_time_, and stopped_.

Referenced by ACE_Countdown_Time(), and update().

00024 {
00025   if (this->max_wait_time_ != 0)
00026     {
00027       this->start_time_ = ACE_OS::gettimeofday ();
00028       this->stopped_ = 0;
00029     }
00030   return 0;
00031 }

int ACE_Countdown_Time::stop void   ) 
 

Subtract the elapsed time from max_wait_time_ and enter a stopped state.

Definition at line 40 of file Countdown_Time.cpp.

References ACE_OS::gettimeofday(), max_wait_time_, start_time_, and stopped_.

Referenced by update(), and ~ACE_Countdown_Time().

00041 {
00042   if (this->max_wait_time_ != 0 && this->stopped_ == 0)
00043     {
00044       ACE_Time_Value elapsed_time =
00045         ACE_OS::gettimeofday () - this->start_time_;
00046 
00047       if (*this->max_wait_time_ > elapsed_time)
00048         *this->max_wait_time_ -= elapsed_time;
00049       else
00050         {
00051           // Used all of timeout.
00052           *this->max_wait_time_ = ACE_Time_Value::zero;
00053           // errno = ETIME;
00054         }
00055       this->stopped_ = 1;
00056     }
00057   return 0;
00058 }

int ACE_Countdown_Time::stopped void   )  const
 

Returns 1 if we've already been stopped, else 0.

Definition at line 34 of file Countdown_Time.cpp.

References stopped_.

00035 {
00036   return stopped_;
00037 }

int ACE_Countdown_Time::update void   ) 
 

Calls stop and then start. max_wait_time_ is modified by the call to stop.

Definition at line 61 of file Countdown_Time.cpp.

References start(), and stop().

Referenced by ACE_WFMO_Reactor::event_handling(), ACE_TP_Reactor::handle_events(), ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_events(), ACE_Process_Manager::wait(), and ACE_Process::wait().

00062 {
00063   return this->stop () == 0 && this->start ();
00064 }


Member Data Documentation

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 start(), and stop().

ACE_Time_Value ACE_Countdown_Time::start_time_ [private]
 

Beginning of the start time.

Definition at line 66 of file Countdown_Time.h.

Referenced by start(), and stop().

int ACE_Countdown_Time::stopped_ [private]
 

Keeps track of whether we've already been stopped.

Definition at line 69 of file Countdown_Time.h.

Referenced by start(), stop(), and stopped().


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:21:11 2006 for ACE by doxygen 1.3.6