diff options
Diffstat (limited to 'ACE/tests/Network_Adapters_Test.cpp')
-rw-r--r-- | ACE/tests/Network_Adapters_Test.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/ACE/tests/Network_Adapters_Test.cpp b/ACE/tests/Network_Adapters_Test.cpp index 4d5aea82d7b..e00f901078d 100644 --- a/ACE/tests/Network_Adapters_Test.cpp +++ b/ACE/tests/Network_Adapters_Test.cpp @@ -28,6 +28,8 @@ #include "ace/Timer_Queue.h" #include "ace/OS_NS_string.h" #include "ace/OS_NS_signal.h" +#include "ace/Timer_Heap.h" +#include "ace/Auto_Ptr.h" #include "Network_Adapters_Test.h" @@ -1035,8 +1037,27 @@ run_main (int argc, ACE_TCHAR *argv[]) ACE_NEW_RETURN (main_reactor, ACE_Reactor, -1); (void) ACE_High_Res_Timer::global_scale_factor (); - main_reactor->timer_queue ()->gettimeofday - (&ACE_High_Res_Timer::gettimeofday_hr); + + // Change the source of time in the reactor to the high-resolution + // timer. Why does this test require such precision for a 1 second + // timer is beyond me ... I think it is a cut&paste error. + // + // The use of auto_ptr<> is optional, ACE uses dangerous memory + // management idioms everywhere, I thought I could demonstrate how + // to do it right in at least one test. Notice the lack of + // ACE_NEW_RETURN, that monstrosity has no business in proper C++ + // code ... + auto_ptr<ACE_Timer_Heap_Variable_Time_Source> tq( + new ACE_Timer_Heap_Variable_Time_Source); + // ... notice how the policy is in the derived timer queue type. + // The abstract timer queue does not have a time policy ... + tq->set_time_policy(&ACE_High_Res_Timer::gettimeofday_hr); + // ... and then the timer queue is replaced. Strangely, the reactor + // does *not* copy the timers, it just deletes the existing timer + // queue .... + main_reactor->timer_queue(tq.get()); + // ... the reactor has assumed ownership, release the auto_ptr<> ... + tq.release(); /** * Stop_Handler's is supposed to stop the activity of all |