| ACE_Reactor *r = ACE_Reactor::instance
(); r->timer_queue ()-> gettimeofday (&ACE_High_Res_Timer::gettimeofday_hr); |
| "Steve Huston"
<shu...@riverace.com>
26.03.2010 21:14 |
|
--
Steve Huston, Riverace Corporation
Total Lifecycle Support for Your Networked Applications
http://www.riverace.com
-----Original Message-----
From: ace-user...@list.isis.vanderbilt.edu [mailto:ace-user...@list.isis.vanderbilt.edu]
On Behalf Of Christian...@rohde-schwarz.com
Sent: Friday, March 26, 2010 2:56 PM
To: ace-...@list.isis.vanderbilt.edu
Subject: [ace-users] ACE timers dependend on absolute system time
Hi,
we are making heavy use of ACE timers using the ACE_Thread_Timer_Queue_Adapter
template on several Windows platforms.
Our problem is that these timer heavily depend on the absolute system time.
As I understand it, a timer event is scheduled "for some time in the
future". But when the system clock is changed, the effect is that
handle_timeout is either called too fast (when system clock is moved forward),
or not called at all for a longer time (when the system clock is moved
backward). The former sometimes causes our software to run into timeout
situations even when everything is OK. The latter causes out watchdogs
to time out since keep-alive messages are not scheduled in time.
Is there some replacement timer in the ACE framework that only relies on
relative times? I am thinking of something which works like WM_TIMER message
in Windows.
I know I could build my own active timer task simple by creating an ACE
task which runs an endless loop sleeping for some seconds and then calling
a timeout callback. But how could I inject this class into ACE method that
take a timeout value (e. g. ACE_Connector::connect)?
Here is some sample code showing what we are doing:
#include <iostream>
#include <ace/Event_Handler.h>
#include <ace/OS.h>
#include <ace/Reactor.h>
#include <ace/Time_Value.h>
#include <ace/Timer_Heap.h>
#include <ace/Timer_Queue_Adapters.h>
int _startTickCount = ::GetTickCount();
class MyEventHandler : public
ACE_Event_Handler
{
virtual int
handle_timeout(const
ACE_Time_Value& current_time, const
void* act)
{
ACE_Time_Value now(ACE_OS::gettimeofday());
std::cout << __FUNCTION__
<< ",
TickCount: " << (::GetTickCount() - _startTickCount)
/ 1000
<< ",
TimeOfDay: " << now.sec()
<< std::endl;
return
0;
}
};
void run()
{
MyEventHandler eventHandler;
typedef ACE_Thread_Timer_Queue_Adapter<ACE_Timer_Heap>
ActiveTimer;
ActiveTimer timer;
const ACE_Time_Value
delay(5);
timer.schedule(&eventHandler, NULL, delay, delay);
timer.activate();
ACE_Reactor::instance()->run_reactor_event_loop();
}
int _tmain(int
argc, _TCHAR* argv[])
{
ACE::init();
run();
ACE::fini();
return 0;
}
Thanks for any ideas,
Chris