# Include <iostream>
# Include <unistd. h>
# Include "ACE/timer_queue_adapters.h"
# Include "ACE/event_handler.h"
# Include "ACE/timer_wheel.h"
# Include "ACE/reactor. H"
# Include "ACE/high_res_timer.h"
Using namespace STD;
Ace_thread_timer_queue_adapter <ace_timer_wheel> active_timer _;
Class ctasktimerhandler: Public ace_event_handler
{
Public:
Ctasktimerhandler (void ){};
Virtual ~ Ctasktimerhandler (void ){};
Enum {timer_notset =-1, timer_cancelled =-2, timer_fired =-3 };
Virtual int handle_timeout (const ace_time_value & current_time, const void * Act)
{
Cout <"time out" <Endl;
Return 0;
}
};
Void starttimer ()
{
Static ctasktimerhandler HDL;
// Active_timer _. Reactor (ace_reactor: instance ());
// Active_timer _. Reactor ()-> timer_queue ()-> gettimeofday (ace_high_res_timer: gettimeofday_hr );
Const ace_time_value curr_ TV = ace_high_res_timer: gettimeofday_hr ();
Long timerid = active_timer _. Schedule (& HDL, 0, curr_ TV + ace_time_value (1), ace_time_value (1 ));
If (timerid <0)
{
Cout <"schedule time failed" <Endl;
}
Active_timer _. timer_queue ()-> gettimeofday (ace_high_res_timer: gettimeofday_hr );
Active_timer _. Activate ();
}
Int main ()
{
Ace_high_res_timer: global_scale_factor ();
Starttimer ();
Sleep (2 );
For (;;)
{
Sleep (7 );
Sleep (1 );
}
}
/*
Int ace_tmain (INT, ace_tchar * [])
{
Ace_high_res_timer: global_scale_factor ();
Starttimer ();
Sleep (2 );
For (;;)
{
Sleep (7000 );
Sleep (1 );
}
}
*/