diff options
author | mcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-12-15 11:09:41 +0000 |
---|---|---|
committer | mcorino <mcorino@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2011-12-15 11:09:41 +0000 |
commit | 9d1004206324867a4287e99b9675d24e536fa090 (patch) | |
tree | 89d59383f294627917ee3cf054f347884a914f32 /ACE/tests/Network_Adapters_Test.cpp | |
parent | b8d69007a4e25977f11cc3de8eb3793c0c61161a (diff) | |
download | ATCD-9d1004206324867a4287e99b9675d24e536fa090.tar.gz |
Thu Dec 15 11:00:00 UTC 2011 Martin Corino <mcorino@remedy.nl>
Merged timer_policy branch.
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 |