Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Countdown_Time Class Reference

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

#include <OS.h>

Collaboration diagram for ACE_Countdown_Time:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Countdown_Time (ACE_Time_Value *max_wait_time)
 Cache the <max_wait_time> and call <start>. More...

 ~ACE_Countdown_Time (void)
 Call <stop>. More...

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

int stop (void)
 Subtract the elapsed time from max_wait_time_ and enter a stopped state. More...

int update (void)
 Calls stop and then start. max_wait_time_ is modified by the call to stop. More...

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


Private Attributes

ACE_Time_Valuemax_wait_time_
 Maximum time we were willing to wait. More...

ACE_Time_Value start_time_
 Beginning of the start time. More...

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


Detailed Description

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 668 of file OS.h.


Constructor & Destructor Documentation

ACE_Countdown_Time::ACE_Countdown_Time ACE_Time_Value   max_wait_time
 

Cache the <max_wait_time> and call <start>.

Definition at line 401 of file OS.cpp.

References start.

00402   : max_wait_time_ (max_wait_time),
00403     stopped_ (0)
00404 {
00405   this->start ();
00406 }

ACE_Countdown_Time::~ACE_Countdown_Time void   
 

Call <stop>.

Definition at line 408 of file OS.cpp.

References stop.

00409 {
00410   this->stop ();
00411 }


Member Function Documentation

ACE_INLINE int ACE_Countdown_Time::start void   
 

Cache the current time and enter a start state.

Definition at line 11094 of file OS.i.

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

Referenced by ACE_Countdown_Time, and update.

11095 {
11096   if (this->max_wait_time_ != 0)
11097     {
11098       this->start_time_ = ACE_OS::gettimeofday ();
11099       this->stopped_ = 0;
11100     }
11101   return 0;
11102 }

ACE_INLINE int ACE_Countdown_Time::stop void   
 

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

Definition at line 11111 of file OS.i.

References ACE_OS::gettimeofday, max_wait_time_, start_time_, stopped_, and ACE_Time_Value::zero.

Referenced by update, and ~ACE_Countdown_Time.

11112 {
11113   if (this->max_wait_time_ != 0 && this->stopped_ == 0)
11114     {
11115       ACE_Time_Value elapsed_time =
11116         ACE_OS::gettimeofday () - this->start_time_;
11117 
11118       if (*this->max_wait_time_ > elapsed_time)
11119         *this->max_wait_time_ -= elapsed_time;
11120       else
11121         {
11122           // Used all of timeout.
11123           *this->max_wait_time_ = ACE_Time_Value::zero;
11124           // errno = ETIME;
11125         }
11126       this->stopped_ = 1;
11127     }
11128   return 0;
11129 }

ACE_INLINE int ACE_Countdown_Time::stopped void    const
 

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

Definition at line 11105 of file OS.i.

References stopped_.

11106 {
11107   return stopped_;
11108 }

ACE_INLINE int ACE_Countdown_Time::update void   
 

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

Definition at line 11132 of file OS.i.

References start, and stop.

Referenced by ACE_WFMO_Reactor::event_handling, ACE_TP_Reactor::handle_events, ACE_Select_Reactor_T::handle_events, ACE_Process_Manager::wait, and ACE_Process::wait.

11133 {
11134   return this->stop () == 0 && this->start ();
11135 }


Member Data Documentation

ACE_Time_Value* ACE_Countdown_Time::max_wait_time_ [private]
 

Maximum time we were willing to wait.

Definition at line 694 of file OS.h.

Referenced by start, and stop.

ACE_Time_Value ACE_Countdown_Time::start_time_ [private]
 

Beginning of the start time.

Definition at line 697 of file OS.h.

Referenced by start, and stop.

int ACE_Countdown_Time::stopped_ [private]
 

Keeps track of whether we've already been stopped.

Definition at line 700 of file OS.h.

Referenced by start, stop, and stopped.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:46:57 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002