本文整理汇总了C++中ACE_Reactor::run_reactor_event_loop方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Reactor::run_reactor_event_loop方法的具体用法?C++ ACE_Reactor::run_reactor_event_loop怎么用?C++ ACE_Reactor::run_reactor_event_loop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Reactor
的用法示例。
在下文中一共展示了ACE_Reactor::run_reactor_event_loop方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handler
static void
test_for_spin (ACE_Reactor &reactor)
{
Handler handler (reactor, true);
// This should trigger a call to <handle_input>.
ssize_t result =
ACE::send_n (handler.pipe_.write_handle (),
message,
ACE_OS::strlen (message));
if (result != ssize_t (ACE_OS::strlen (message)))
ACE_ERROR ((LM_ERROR, ACE_TEXT ("Handler sent %b bytes; should be %B\n"),
result, ACE_OS::strlen (message)));
reactor.run_reactor_event_loop ();
if (0 != reactor.remove_handler (handler.pipe_.read_handle (),
ACE_Event_Handler::ALL_EVENTS_MASK |
ACE_Event_Handler::DONT_CALL))
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("test_for_spin, remove pipe")));
if (0 == reactor.remove_handler (handler.other_pipe_.write_handle (),
ACE_Event_Handler::ALL_EVENTS_MASK |
ACE_Event_Handler::DONT_CALL))
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("test_for_spin remove other_pipe succeeded ")
ACE_TEXT ("but shouldn't\n")));
}
示例2: event_loop
static ACE_THR_FUNC_RETURN event_loop (void *arg) {
ACE_Reactor *reactor = static_cast<ACE_Reactor *> (arg);
reactor->owner (ACE_OS::thr_self ());
reactor->run_reactor_event_loop ();
return 0;
}
示例3:
int
Task::svc()
{
ACE_DEBUG ((LM_DEBUG, "(%P|%t) Starting thread for %s\n", endpoint_));
(void) reactor_.run_reactor_event_loop();
return 0;
}
示例4: reactor
int
run_main (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT ("Timer_Cancellation_Test"));
ACE_Reactor reactor (new ACE_TP_Reactor,
1);
Deadlock deadlock;
deadlock.reactor (&reactor);
Event_Handler handler (deadlock);
// Scheduler a timer to kick things off.
reactor.schedule_timer (&handler,
0,
ACE_Time_Value (1));
// Run the event loop for a while.
ACE_Time_Value timeout (4);
reactor.run_reactor_event_loop (timeout);
ACE_END_TEST;
return 0;
}
示例5: run
void run ()
{
uint16 raport = sConfig.GetIntDefault ("Ra.Port", 3443);
std::string stringip = sConfig.GetStringDefault ("Ra.IP", "0.0.0.0");
ACE_INET_Addr listen_addr(raport, stringip.c_str());
if (m_Acceptor->open (listen_addr, m_Reactor, ACE_NONBLOCK) == -1)
{
sLog.outError ("MaNGOS RA can not bind to port %d on %s", raport, stringip.c_str ());
}
sLog.outString ("Starting Remote access listner on port %d on %s", raport, stringip.c_str ());
while (!m_Reactor->reactor_event_loop_done())
{
ACE_Time_Value interval (0, 10000);
if (m_Reactor->run_reactor_event_loop (interval) == -1)
break;
if(World::IsStopped())
{
m_Acceptor->close();
break;
}
}
sLog.outString("RARunnable thread ended");
}
示例6: threadFunc
/**
* 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_TRACE("threadFunc(void *)");
ACE_Reactor *reactor = (ACE_Reactor *) arg;
reactor->run_reactor_event_loop();
return 0;
}
示例7:
static void *run_reactor (void *pReactor)
{
ACE_Reactor *pLogReactor = (ACE_Reactor *)pReactor;
pLogReactor->owner(ACE_Thread_Manager::instance ()->thr_self());
pLogReactor->run_reactor_event_loop ();
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) %M run_reactor exit[%N,%l]\n")));
return 0;
}
示例8: main
int main(int argc, char *argv[])
{
ACE_Reactor reactor;
Server_Logging_Deamon *server = 0;
ACE_NEW_RETURN(server, Server_Logging_Deamon(argc, argv, &reactor), 1);
if (reactor.run_reactor_event_loop() == -1)
ACE_ERROR_RETURN((LM_ERROR, "%p\n", "run_reactor_event_loop()"), 1);
return 0;
}
示例9: main
int main(int argc, char* argv[])
{
ACE_Reactor reactor;
ACE_Acceptor<EchoServerHandler, ACE_SOCK_Acceptor> echoServerAcceptor;
if (echoServerAcceptor.open(ACE_INET_Addr(DEFAULT_PORT), &reactor) == -1)
return 1;
reactor.run_reactor_event_loop();
return 0;
}
示例10: event_loop
//for ACE_TP_Reactor
static ACE_THR_FUNC_RETURN event_loop (void *arg)
{
//ACE_Reactor *reactor = ACE_static_cast(ACE_Reactor *, arg);
ACE_Reactor *reactor = static_cast< ACE_Reactor *> (arg);
ACE_DEBUG((LM_INFO, "[%D] ace tp reactor event loop, tid=%d,pid=%d\n"
, ACE_OS::thr_self ()
, ACE_OS::getpid()
));
reactor->owner(ACE_OS::getpid());
reactor->run_reactor_event_loop ();
return 0;
}
示例11: reactor
int
run_main (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT ("Bug_1890_Regression_Test"));
bool success = true;
// Bug 1890 is all about ACE_Select_Reactor, so run it on that reactor
// regardless of platform.
ACE_Select_Reactor *impl_ptr = 0;
ACE_NEW_RETURN (impl_ptr, ACE_Select_Reactor, -1);
auto_ptr<ACE_Select_Reactor> auto_impl (impl_ptr);
ACE_Reactor reactor (impl_ptr);
// Create the timer, this is the main driver for the test
Timer * timer = new Timer;
// Initialize the timer and register with the reactor
if (-1 == timer->open (&reactor))
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("Cannot initialize timer")),
-1);
}
reactor.run_reactor_event_loop ();
// Verify that the results are what we expect
if (!(success = timer->check_expected_results ()))
ACE_ERROR ((LM_ERROR, ACE_TEXT ("Test failed\n")));
// Cleanup
timer->close ();
delete timer;
ACE_END_TEST;
return success ? 0 : -1;
}
示例12: testNativeReactor
void testNativeReactor (int, ACE_TCHAR *[])
{
ACE_DEBUG ((LM_INFO, ACE_TEXT ("Testing autotest using native reactor\n")));
ACE_Reactor reactor;
HandlersRegister handlersRegister (&reactor);
ACE_Time_Value testTime (TotalTestTime / 1000, (TotalTestTime % 1000) * 1000);
if (0 <= handlersRegister.scheduleTimers (testTime) &&
0 <= handlersRegister.registerDgramHandlers () &&
0 <= handlersRegister.registerTCPHandlers ())
{
reactor.run_reactor_event_loop (testTime);
if (0 != handlersRegister.analyze ())
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Test failed for native reactor. "
"Fix QtReactor_Test or ACE_Reactor.\n")));
else
ACE_ERROR ((LM_INFO, ACE_TEXT ("Test seems to work with native reactor.\n")));
}
}
示例13: ACE_TMAIN
/* Program's entry point */
int ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
ACE_OS::printf("Usage: %s [port-number]\n", argv[0]);
u_short port = argc < 2 ? ACE_DEFAULT_SERVER_PORT : ACE_OS::atoi(argv[1]);
ACE_INET_Addr addr(port);
ACE_DEBUG((LM_DEBUG,
"(%t) Program's entry point\n"));
ACE_OS::printf("listening at port %d\n", port);
// Implement a main() function that:
//1. Creates an Echo_Task instance and have it spawn a pool of N threads
// (where N > 1) within itself (Echo_Task::activate()).
Echo_Task echo_task;
Echo_Task *ptask = &echo_task;
//Create POOL_SIZE kernel-level threads and allow the new threads to be joined with.
echo_task.activate(THR_NEW_LWP | THR_JOINABLE, POOL_SIZE);
///2. Creates an Echo_Acceptor instance and associate it with the Echo_Task.
Echo_Acceptor acceptor;
acceptor.echo_task(ptask); // Using a setter method defined in Echo_Acceptor
//3. Creates an ACE_Reactor(or use the singleton instance of the ACE_Reactor)
ACE_Reactor *reactor = ACE_Reactor::instance();
//4. Registers the Echo_Acceptor instance with the reactor
acceptor.open(addr, reactor);
//5. Run the reactor's event loop [ACE_Reactor::run_reactor_event_loop()]
// to wait for connections/data to arrive from a client.
reactor->run_reactor_event_loop();
// Wait for all threads to exit
ACE_Thread_Manager::instance()->wait();
return 0;
}
示例14: reactor
int
run_main (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT ("Bug_2540_Regression_Test"));
// Bug 2540 is all about ACE_Select_Reactor, so run it on that reactor
// regardless of platform. In particular, this test relies on a handler
// that doesn't consume ready-to-read data being called back - this won't
// happen with ACE_WFMO_Reactor.
ACE_Select_Reactor select_reactor;
ACE_Reactor reactor (&select_reactor);
// Create the timer, this is the main driver for the test
Timer * timer = new Timer;
// Initialize the timer and register with the reactor
if (-1 == timer->open (&reactor))
{
ACE_ERROR_RETURN ((LM_ERROR, "Cannot initialize timer\n"), -1);
}
reactor.run_reactor_event_loop ();
// Verify that the results are what we expect
if (!timer->check_expected_results ())
{
ACE_ERROR_RETURN ((LM_ERROR, "Test failed\n"), -1);
}
// Cleanup
timer->close ();
delete timer;
ACE_END_TEST;
return 0;
}
示例15: reactor
void
test (ACE_Reactor_Impl &reactor_impl,
const char *reactor_type)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("\nTesting with %C\n\n"),
reactor_type));
ACE_Reactor reactor (&reactor_impl,
0);
Event_Handler *e = new Event_Handler (reactor,
ACE_INVALID_HANDLE,
ACE_INVALID_HANDLE);
if (!e->ok_)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("Error initializing test; aborting.\n")));
delete e;
return;
}
reactor.run_reactor_event_loop ();
}