I have an application that starts up and processes queued items. The items are processed at a timer framed rate. This is implemented using the ACE_Reactor class.
The bit of code that kicks this off is:
void start() {
ACE_Reactor::instance()->schedule_timer( this, NULL, ACE_Time_Value(0,1000), ACE_Time_Value(0,1000) );
ACE_Reactor::instance()->run_reactor_event_loop();
}
handle_timeout (const ACE_Time_Value ¤t_time, const void *act) {
<Process item>
If (more items left)
return 0;
else
return -1;
}
This causes the handle_timeout() method to be called which then processes one item off the queue. While there are more items in the queue the callback returns 0. When the queue is empty the callback returns -1 which stops the reactor loop.
The problem is that when the method returns -1 run_reactor_event_loop();
is still blocking. I'd like the application to complete return a status code and exit. I am having a hard time finding good documentation w/ examples.
Am I missing something?
The return value doesn't mean the reactor ends running. In order to have run_reactor_event_loop()
to return you have to call somewhere ACE_Reactor::instance ()->end_reactor_event_loop ()
, see for example the ACE examples under ACE_wrappers/examples/APG/Reactor