1 #include "Custom_Time_Policy_Strategy.h"
3 #include "ace/Timer_Heap_T.h"
4 #include "ace/Event_Handler_Handle_Timeout_Upcall.h"
5 #include "ace/High_Res_Timer.h"
7 #if (TAO_HAS_TIME_POLICY == 1)
9 class TPTEST_Export Custom_Time_Policy
12 /// Return the current time according to this policy
13 ACE_Time_Value
operator() () const
15 ACE_Time_Value tv
= ACE_High_Res_Timer::gettimeofday_hr ();
16 return (tv
+= ACE_Time_Value (10, 0));
18 /// Noop. Just here to satisfy backwards compatibility demands.
19 void set_gettimeofday (ACE_Time_Value (*)(void)) {}
22 static ACE_Time_Policy_T
<Custom_Time_Policy
> custom_time_policy_
;
24 Custom_Time_Policy_Strategy::~Custom_Time_Policy_Strategy ()
28 ACE_Timer_Queue
* Custom_Time_Policy_Strategy::create_timer_queue ()
30 ACE_Timer_Queue
* tmq
= 0;
32 typedef ACE_Timer_Heap_T
<ACE_Event_Handler
*,
33 ACE_Event_Handler_Handle_Timeout_Upcall
,
34 ACE_SYNCH_RECURSIVE_MUTEX
,
35 Custom_Time_Policy
> timer_queue_type
;
36 ACE_NEW_RETURN (tmq
, timer_queue_type (), 0);
42 Custom_Time_Policy_Strategy::destroy_timer_queue (ACE_Timer_Queue
*tmq
)
47 ACE_Dynamic_Time_Policy_Base
* Custom_Time_Policy_Strategy::get_time_policy ()
49 return &custom_time_policy_
;
53 ACE_STATIC_SVC_DEFINE (Custom_Time_Policy_Strategy
,
54 ACE_TEXT ("CUSTOM_TIME_POLICY"),
56 &ACE_SVC_NAME (Custom_Time_Policy_Strategy
),
57 ACE_Service_Type::DELETE_THIS
|
58 ACE_Service_Type::DELETE_OBJ
,
61 ACE_FACTORY_DEFINE (TPTEST
, Custom_Time_Policy_Strategy
)
63 #endif /* TAO_HAS_TIME_POLICY */