/** * @file * * ACE reactor demonstration. Compile with * * g++ -o ace_reactor ace_reactor.cpp -lACE * * @author Martin Kolleck * @date 2007-01-24 */ #include #include #include /** * This is the function run by all threads in the thread pool. * * @param arg is expected to be of type (ACE_Reactor *) */ ACE_THR_FUNC_RETURN threadFunc(void *arg) { ACE_Reactor *reactor = (ACE_Reactor *) arg; reactor->run_reactor_event_loop(); return 0; } /** * The main function sets up the TP reactor and then waits for the termination * of the reactor. */ int main(void) { // create a reactor from a TP reactor ACE_TP_Reactor tpReactor; ACE_Reactor reactor(&tpReactor); // spawn some threads which run the reactor event loop(s) ACE_Thread_Manager::instance()->spawn_n(3, threadFunc, &reactor); // let the thread manager wait for all threads ACE_Thread_Manager::instance()->wait(); return 0; }