本文整理汇总了C++中ACE_Reactor类的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Reactor类的具体用法?C++ ACE_Reactor怎么用?C++ ACE_Reactor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACE_Reactor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
Sender_exec_i::start (void)
{
ACE_Reactor* reactor = 0;
::CORBA::Object_var ccm_object = this->ciao_context_->get_CCM_object();
if (!::CORBA::is_nil (ccm_object.in ()))
{
::CORBA::ORB_var orb = ccm_object->_get_orb ();
if (!::CORBA::is_nil (orb.in ()))
{
reactor = orb->orb_core ()->reactor ();
}
}
if (reactor)
{
// calculate the interval time
long const usec = 1000000 / this->rate_;
if (reactor->schedule_timer (
this->ticker_,
0,
ACE_Time_Value (3, usec),
ACE_Time_Value (0, usec)) == -1)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("Sender_exec_i::start : ")
ACE_TEXT ("Error scheduling timer")));
}
}
else
{
throw ::CORBA::INTERNAL ();
}
}
示例2: ACE_TEXT
int
ImR_Activator_i::handle_exit (ACE_Process * process)
{
if (debug_ > 0)
{
ORBSVCS_DEBUG
((LM_DEBUG,
ACE_TEXT ("Process %d exited with exit code %d, delay = %d\n"),
process->getpid (), process->return_value (), this->induce_delay_));
}
if (this->induce_delay_ > 0 && this->active_check_pid_ == ACE_INVALID_PID)
{
ACE_Reactor *r = this->orb_->orb_core()->reactor();
ACE_Time_Value dtv (0, this->induce_delay_ * 1000);
pid_t pid = process->getpid();
Act_token_type token = static_cast<Act_token_type>(pid);
r->schedule_timer (this, reinterpret_cast<void *>(token), dtv );
}
else
{
this->handle_exit_i (process->getpid());
}
return 0;
}
示例3: doit
void
device_averager::deactivate()
{
doit( device_state::command_off );
ACE_Reactor * reactor = acewrapper::singleton::ReactorThread::instance()->get_reactor();
reactor->cancel_timer( this );
}
示例4: worker
static void *
worker (void *args)
{
ACE_Reactor *reactor = (ACE_Reactor *) args;
reactor->owner (ACE_Thread::self ());
ACE_Time_Value timeout (4);
for (;;)
{
//ACE_DEBUG ((LM_DEBUG, "(%t) calling handle_events\n"));
switch (reactor->handle_events (timeout))
{
case -1:
ACE_ERROR_RETURN ((LM_ERROR, "(%t) %p\n", "reactor"), 0);
/* NOTREACHED */
case 0:
ACE_ERROR_RETURN ((LM_ERROR, "(%t) timeout\n"), 0);
/* NOTREACHED */
}
// ACE_DEBUG ((LM_DEBUG, "(%t) done with handle_events\n"));
}
ACE_NOTREACHED(return 0);
}
示例5: run_main
// If any command line arg is given, run the test with high res timer
// queue. Else run it normally.
int
run_main (int argc, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT ("Reactor_Timer_Test"));
if (argc > 1)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Running with high-res timer queue\n")));
ACE_Reactor *r = ACE_Reactor::instance ();
(void) ACE_High_Res_Timer::global_scale_factor ();
r->timer_queue ()->gettimeofday (&ACE_High_Res_Timer::gettimeofday_hr);
}
// Register all different handlers, i.e., one per timer.
test_registering_all_handlers ();
// Now try multiple timers for ONE event handler (should produce the
// same result).
test_registering_one_handler ();
// Try canceling handlers with odd numbered timer ids.
test_canceling_odd_timers ();
// Make sure <reset_timer_inverval> works.
test_resetting_timer_intervals ();
ACE_END_TEST;
return 0;
}
示例6: ACE_TMAIN
int
ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
ACE_OS::signal (SIGCLD, SIG_IGN);
ACE_UNUSED_ARG (sa);
parse_args (argc, argv);
OUTPUT_FILE = ACE_OS::open (OUTPUT_FILE_NAME, O_CREAT | O_WRONLY, 0644);
if (OUTPUT_FILE == 0)
return 1;
ACE_Reactor reactor;
Handle_Events handle_events (UDP_PORT, MCAST_ADDR, INTERFACE, reactor);
// main loop
while (!done)
reactor.handle_events ();
ACE_OS::close (OUTPUT_FILE);
cout << "\nbenchd done.\n";
return 0;
}
示例7: addr
// This is run at program initialization
void CommandLineServer::run(void* args)
{
s_log = log4cxx::Logger::getLogger("interface.commandlineserver");
unsigned short tcpPort = (unsigned short)(unsigned long)args;
//unsigned short tcpPort = (unsigned short)*(int*)args;
CommandLineAcceptor peer_acceptor;
ACE_INET_Addr addr (tcpPort);
ACE_Reactor reactor;
CStdString tcpPortString = IntToString(tcpPort);
if (peer_acceptor.open (addr, &reactor) == -1)
{
LOG4CXX_ERROR(s_log, CStdString("Failed to start command line server on port:") + tcpPortString + CStdString(" do you have another instance of orkaudio running?"));
}
else
{
LOG4CXX_INFO(s_log, CStdString("Started command line server on port:")+tcpPortString);
for(;;)
{
reactor.handle_events();
}
}
}
示例8: if
Dispatch_Count_Handler::Dispatch_Count_Handler (void)
{
ACE_Reactor *r = ACE_Reactor::instance ();
this->input_seen_ = this->notify_seen_ = 0;
this->timers_fired_ = 0;
// Initialize the pipe.
if (this->pipe_.open () == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_Pipe::open")));
// Register the "read" end of the pipe.
else if (r->register_handler (this->pipe_.read_handle (),
this,
ACE_Event_Handler::READ_MASK) == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("register_handler")));
// Put something in our pipe and smoke it... ;-)
else if (ACE::send (this->pipe_.write_handle (),
"z",
1) == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("send")));
// Call notify to prime the pump for this, as well.
else if (r->notify (this) == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("notify")));
}
示例9: ACE_TRACE
int
ACE_Process_Manager::append_proc (ACE_Process *proc)
{
ACE_TRACE ("ACE_Process_Manager::append_proc");
// Try to resize the array to twice its existing size if we run out
// of space...
if (this->current_count_ >= this->max_process_table_size_
&& this->resize (this->max_process_table_size_ * 2) == -1)
return -1;
else
{
ACE_Process_Descriptor &proc_desc =
this->process_table_[this->current_count_];
proc_desc.process_ = proc;
proc_desc.exit_notify_ = 0;
#if defined (ACE_WIN32)
// If we have a Reactor, then we're supposed to reap Processes
// automagically. Get a handle to this new Process and tell the
// Reactor we're interested in <handling_input> on it.
ACE_Reactor *r = this->reactor ();
if (r != 0)
r->register_handler (this,
proc->gethandle ());
#endif /* ACE_WIN32 */
this->current_count_++;
return 0;
}
}
示例10: ACE_TEXT
int
ImR_Activator_i::handle_exit (ACE_Process * process)
{
if (debug_ > 0)
{
ORBSVCS_DEBUG
((LM_DEBUG,
ACE_TEXT ("Process %d exited with exit code %d\n"),
process->getpid (), process->return_value ()));
}
if (this->induce_delay_ > 0)
{
ACE_Reactor *r = this->orb_->orb_core()->reactor();
ACE_Time_Value dtv (0, this->induce_delay_ * 1000);
pid_t pid = process->getpid();
#if (ACE_SIZEOF_VOID_P == 8)
ACE_INT64 token = static_cast<ACE_INT64>(pid);
#else
ACE_INT32 token = static_cast<ACE_INT32>(pid);
#endif
r->schedule_timer (this, reinterpret_cast<void *>(token), dtv );
}
else
{
this->handle_exit_i (process->getpid());
}
return 0;
}
示例11: worker
static void *
worker (void *args)
{
ACE_Reactor *reactor = reinterpret_cast<ACE_Reactor *> (args);
// Make this thread the owner of the Reactor's event loop.
reactor->owner (ACE_Thread::self ());
// Use a timeout to inform the Reactor when to shutdown.
ACE_Time_Value timeout (4);
for (;;)
switch (reactor->handle_events (timeout))
{
case -1:
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("(%t) %p\n"),
ACE_TEXT ("reactor")),
0);
/* NOTREACHED */
case 0:
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%t) Reactor shutdown\n")));
return 0;
}
ACE_NOTREACHED (return 0);
}
示例12: 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;
}
示例13: ACE_TMAIN
// server main function
// uses a portable form of the "main" function along with its arguments
int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
{
// instantiate an object of the Proto Handler class
Proto_Handler proto;
// retrieve a reactor. Here we could have retrieved different
// implementations of reactor. For now we get the default singletom
// reactor.
ACE_Reactor *reactor = ACE_Reactor::instance ();
// initialize the proto handler object
if (proto.open (argc, argv, reactor) == -1) {
ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"),
ACE_TEXT ("handler open")));
return -1;
}
// now let the server handle the events
for (;;) {
if (reactor->handle_events () == -1) {
ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) %p\n"),
ACE_TEXT ("handle events")));
return -1;
}
}
// return exit status
return 0;
}
示例14: controller
static ACE_THR_FUNC_RETURN controller (void *arg) {
ACE_Reactor *reactor = static_cast<ACE_Reactor *> (arg);
Quit_Handler *quit_handler = 0;
ACE_NEW_RETURN (quit_handler, Quit_Handler (reactor), 0);
#if defined (ACE_WIN32) && (!defined (ACE_HAS_STANDARD_CPP_LIBRARY) || \
(ACE_HAS_STANDARD_CPP_LIBRARY == 0) || \
defined (ACE_USES_OLD_IOSTREAMS))
for (;;) {
char user_input[80];
ACE_OS::fgets (user_input, sizeof (user_input), stdin);
if (ACE_OS::strcmp (user_input, "quit") == 0) {
reactor->notify (quit_handler);
break;
}
}
#else
for (;;) {
std::string user_input;
std::getline (cin, user_input, '\n');
if (user_input == "quit") {
reactor->notify (quit_handler);
break;
}
}
#endif
return 0;
}
示例15: test_for_spin
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")));
}