3 //=============================================================================
5 * @file Countdown_Time_T.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 //=============================================================================
11 #ifndef ACE_COUNTDOWN_TIME_T_H
12 #define ACE_COUNTDOWN_TIME_T_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/ACE_export.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/Time_Value.h"
23 #include "ace/Time_Policy.h"
24 #include "ace/Copy_Disabled.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 * @class ACE_Countdown_Time
31 * @brief Keeps track of the amount of elapsed time.
33 * This class has a side-effect on the @c max_wait_time -- every
34 * time the stop() method is called the @c max_wait_time is
37 template <typename TIME_POLICY
= ACE_Default_Time_Policy
>
38 class ACE_Countdown_Time_T
: private ACE_Copy_Disabled
41 /// Cache the @a max_wait_time and call @c start().
42 ACE_Countdown_Time_T (ACE_Time_Value
*max_wait_time
,
43 TIME_POLICY
const & time_policy
= TIME_POLICY());
45 /// Destructor, makes sure the max_wait_time that got passed as pointer
46 /// to the constructor is updated with the time elapsed.
47 ~ACE_Countdown_Time_T ();
49 /// Cache the current time and enter a start state.
52 /// Subtract the elapsed time from max_wait_time_ and enter a stopped
56 /// Calls stop and then start. max_wait_time_ is modified by the
60 /// Returns true if we've already been stopped, else false.
61 bool stopped () const;
63 /// Allows applications to control how the timer queue gets the time
65 void set_time_policy(TIME_POLICY
const & time_policy
);
68 /// The policy to return the current time of day
69 TIME_POLICY time_policy_
;
71 /// Maximum time we are monitoring
72 ACE_Time_Value
*max_wait_time_
;
74 /// Copy of the maximum time value, used to avoid nested decrements
75 ACE_Time_Value max_wait_value_
;
77 /// Beginning of the start time.
78 ACE_Time_Value start_time_
;
80 /// Keeps track of whether we've already been stopped.
84 ACE_END_VERSIONED_NAMESPACE_DECL
86 #include /**/ "ace/post.h"
88 #if defined (__ACE_INLINE__)
89 #include "ace/Countdown_Time_T.inl"
90 #endif /* __ACE_INLINE__ */
92 #include "ace/Countdown_Time_T.cpp"
94 #endif /* ACE_COUNTDOWN_TIME_T_H */