1 #ifndef ACE_COUNTDOWN_TIME_T_CPP
2 #define ACE_COUNTDOWN_TIME_T_CPP
4 #include "ace/Countdown_Time_T.h"
6 #if !defined (__ACE_INLINE__)
7 #include "ace/Countdown_Time_T.inl"
8 #endif /* __ACE_INLINE__ */
10 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
12 template <typename TIME_POLICY
> ACE_INLINE
13 ACE_Countdown_Time_T
<TIME_POLICY
>::ACE_Countdown_Time_T (ACE_Time_Value
*max_wait_time
,
14 TIME_POLICY
const & time_policy
)
15 : time_policy_ (time_policy
),
16 max_wait_time_ (max_wait_time
),
17 max_wait_value_ (ACE_Time_Value::zero
),
23 template <typename TIME_POLICY
> ACE_INLINE
24 ACE_Countdown_Time_T
<TIME_POLICY
>::~ACE_Countdown_Time_T ()
29 template <typename TIME_POLICY
> ACE_INLINE
void
30 ACE_Countdown_Time_T
<TIME_POLICY
>::start ()
32 if (this->max_wait_time_
!= 0)
34 this->max_wait_value_
= *this->max_wait_time_
;
35 this->start_time_
= this->time_policy_ ();
36 this->stopped_
= false;
40 template <typename TIME_POLICY
> ACE_INLINE
void
41 ACE_Countdown_Time_T
<TIME_POLICY
>::stop ()
43 if (this->max_wait_time_
!= 0 && !this->stopped_
)
45 ACE_Time_Value
const elapsed_time
=
46 this->time_policy_ () - this->start_time_
;
48 if (elapsed_time
>= ACE_Time_Value::zero
&&
49 this->max_wait_value_
> elapsed_time
)
51 *this->max_wait_time_
= this->max_wait_value_
- elapsed_time
;
55 // Used all of timeout.
56 *this->max_wait_time_
= ACE_Time_Value::zero
;
59 this->stopped_
= true;
63 ACE_END_VERSIONED_NAMESPACE_DECL
65 #endif /* ACE_COUNTDOWN_TIME_T_CPP */