本文整理汇总了C++中ACE_Reactor::remove_handler方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Reactor::remove_handler方法的具体用法?C++ ACE_Reactor::remove_handler怎么用?C++ ACE_Reactor::remove_handler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Reactor
的用法示例。
在下文中一共展示了ACE_Reactor::remove_handler方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
void
Locator_Repository::teardown_multicast ()
{
ACE_Reactor* r = ior_multicast_.reactor ();
if (r != 0) {
r->remove_handler (&ior_multicast_, ACE_Event_Handler::READ_MASK);
ior_multicast_.reactor (0);
}
}
示例3: svc
int MyTask::svc()
{
ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%t) enter MyTask::svc()\n\n")));
//initialization
selector = new ACE_Select_Reactor;
ACE_Reactor* reactor = new ACE_Reactor(selector);
ACE_Reactor::instance(reactor); //then, ACE_Reactor::instance() is reactor
this->reactor(reactor); //this reactor_ of ACE_Event_Handler can not be set
//register socket handler
Handler handler(UDP_PORT);
if (reactor->register_handler(&handler, ACE_Event_Handler::READ_MASK) == -1)
{
ACE_ERROR((LM_ERROR, "%p\n", "cant't register with Reactor in MyTask::svc()\n"));
return -1;
}
//spawn mytask2
mytask2::instance()->open(&handler);
//handle_events in forever-loop until receive two data packets from socket, then, it will notify the MY_EXIT_HANDLER
while (exit_flag == 0)
{
int result = reactor->handle_events(); //timeout will not occur at all
if (result)
{
ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%t) handle_events() succeed, result = %d\n\n"), result));
if (RECV_COUNT == handler.get_count())
{
ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%t) MyTask::svc() notify the exit handler\n")));
ACE_Reactor::instance()->notify(&handler, ACE_Event_Handler::EXCEPT_MASK);
}
if (handler.get_flag())
exit_flag = 1;
}
else
{
ACE_ERROR((LM_ERROR, "%p\n", "handle_events() failed\n"));
return -1;
}
}
if (reactor->remove_handler(&handler, ACE_Event_Handler::READ_MASK |
ACE_Event_Handler::DONT_CALL) == -1)
{
ACE_ERROR((LM_ERROR, "%p\n", "cant't remove handler from Reactor\n"));
return -1;
}
delete reactor;
reactor = NULL;
ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%t) exit MyTask::svc()\n\n")));
return 0;
}
示例4:
void
RtpsUdpReceiveStrategy::stop_i()
{
ACE_Reactor* reactor = link_->get_reactor();
if (reactor == 0) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: ")
ACE_TEXT("RtpsUdpReceiveStrategy::stop_i: ")
ACE_TEXT("NULL reactor reference!\n")));
return;
}
reactor->remove_handler(link_->unicast_socket().get_handle(),
ACE_Event_Handler::READ_MASK);
if (link_->config()->use_multicast_) {
reactor->remove_handler(link_->multicast_socket().get_handle(),
ACE_Event_Handler::READ_MASK);
}
}
示例5:
int
Sender::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
{
ACE_Reactor * TPReactor = ACE_Reactor::instance ();
TPReactor->remove_handler (this,
ACE_Event_Handler::ALL_EVENTS_MASK |
ACE_Event_Handler::DONT_CALL); // Don't call handle_close
this->reactor (0);
this->destroy ();
return 0;
}
示例6:
void
UdpReceiveStrategy::stop_i()
{
ACE_Reactor* reactor = this->link_->get_reactor();
if (reactor == 0) {
ACE_ERROR((LM_ERROR,
ACE_TEXT("(%P|%t) ERROR: ")
ACE_TEXT("UdpReceiveStrategy::stop_i: ")
ACE_TEXT("NULL reactor reference!\n")));
return;
}
reactor->remove_handler(this, ACE_Event_Handler::READ_MASK);
}
示例7: timeout
int
TAO_Acceptor::handle_accept_error (ACE_Event_Handler* base_acceptor)
{
if (errno == EMFILE || errno == ENFILE)
{
if (TAO_debug_level > 0)
TAOLIB_DEBUG ((LM_DEBUG, "TAO (%P|%t) - "
"TAO_Acceptor::handle_accept_error - "
"Too many files open\n"));
// If the user has decided to stop accepting when the file handles
// run out, just return -1;
if (this->error_retry_delay_ == 0)
return -1;
// Get the reactor. If there isn't one, which isn't very likely,
// then just return -1.
ACE_Reactor* reactor = base_acceptor->reactor ();
if (reactor == 0)
return -1;
// So that the reactor doesn't completely remove this handler from
// the reactor, register it with the except mask. It should be
// removed in the timer handler.
reactor->register_handler (base_acceptor,
ACE_Event_Handler::EXCEPT_MASK);
// Remove the handler so that the reactor doesn't attempt to
// process this handle again (and tightly spin).
reactor->remove_handler (base_acceptor,
ACE_Event_Handler::ACCEPT_MASK |
ACE_Event_Handler::DONT_CALL);
// Schedule a timer so that we can resume the handler in hopes
// that some file handles have freed up.
ACE_Time_Value timeout (this->error_retry_delay_);
reactor->schedule_timer (base_acceptor, 0, timeout);
}
// We want to keep accepting in all other situations.
return 0;
}
示例8:
TAO_IFR_Server::~TAO_IFR_Server (void)
{
// Get reactor instance from TAO.
ACE_Reactor *reactor = this->orb_->orb_core ()->reactor ();
if ( this->ior_multicast_ )
{
// Remove event handler for the ior multicast.
if (reactor->remove_handler (this->ior_multicast_,
ACE_Event_Handler::READ_MASK)
== -1)
{
ORBSVCS_DEBUG ((
LM_DEBUG,
ACE_TEXT ("Interface Repository: cannot remove handler\n")
));
}
}
delete this->config_;
delete this->ior_multicast_;
}
示例9:
template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input (ACE_HANDLE)
{
ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_input");
int result = 0;
// Cancel any timer that might be pending.
this->cancel ();
// Try to find out if the implementation of the reactor that we are
// using requires us to reset the event association for the newly
// created handle. This is because the newly created handle will
// inherit the properties of the listen handle, including its event
// associations.
ACE_Reactor *reactor = this->reactor ();
bool reset_new_handle = false;
// There is a use-case whereby this object will be gone upon return
// from shared_accept - if the Svc_Handler deletes this Oneshot_Acceptor
// during the shared_accept/activation steps. So, do whatever we need
// to do with this object before calling shared_accept.
if (reactor)
{
reset_new_handle = reactor->uses_event_associations ();
reactor->remove_handler
(this,
ACE_Event_Handler::ACCEPT_MASK | ACE_Event_Handler::DONT_CALL);
}
if (this->shared_accept (this->svc_handler_, // stream
0, // remote address
0, // timeout
this->restart_, // restart
reset_new_handle // reset new handle
) == -1)
result = -1;
return result;
}
示例10: defined
int
ACE_Process_Manager::remove_proc (size_t i)
{
ACE_TRACE ("ACE_Process_Manager::remove_proc");
// If there's an exit_notify_ <Event_Handler> for this pid, call its
// <handle_close> method.
if (this->process_table_[i].exit_notify_ != 0)
{
this->process_table_[i].exit_notify_->handle_close
(this->process_table_[i].process_->gethandle(),
0);
this->process_table_[i].exit_notify_ = 0;
}
#if defined (ACE_WIN32)
ACE_Reactor *r = this->reactor ();
if (r != 0)
r->remove_handler (this->process_table_[i].process_->gethandle (),
ACE_Event_Handler::DONT_CALL);
#endif /* ACE_WIN32 */
this->process_table_[i].process_->unmanage ();
this->process_table_[i].process_ = 0;
this->current_count_--;
if (this->current_count_ > 0)
// Compact the table by moving the last item into the slot vacated
// by the index being removed (this is a structure assignment).
this->process_table_[i] =
this->process_table_[this->current_count_];
return 0;
}
示例11:
int
TAO_Acceptor::handle_expiration (ACE_Event_Handler* base_acceptor)
{
// Get the reactor. If there isn't one, which isn't very likely, then
// just return -1;
ACE_Reactor* reactor = base_acceptor->reactor ();
if (reactor == 0)
return -1;
if (TAO_debug_level > 0)
TAOLIB_DEBUG ((LM_DEBUG, "TAO (%P|%t) - "
"TAO_Acceptor::handle_expiration - "
"Re-registering the acceptor\n"));
// Try again to allow incoming connections
reactor->register_handler (base_acceptor, ACE_Event_Handler::ACCEPT_MASK);
// Remove the except mask that was added during the handling of the
// accept() error. That is the only reason that we're in this method
// in the first place.
reactor->remove_handler (base_acceptor, ACE_Event_Handler::EXCEPT_MASK |
ACE_Event_Handler::DONT_CALL);
return 0;
}
示例12: handler
static bool
test_reactor_dispatch_order (ACE_Reactor &reactor)
{
Handler handler (reactor);
if (!handler.ok_)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("Error initializing test; abort.\n")));
return false;
}
bool ok_to_go = 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)));
ok_to_go = false;
}
// This should trigger a call to <handle_timeout>.
if (-1 == reactor.schedule_timer (&handler,
0,
ACE_Time_Value (0)))
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("schedule_timer")));
ok_to_go = false;
}
// Suspend the handlers - only the timer should be dispatched
ACE_Time_Value tv (1);
reactor.suspend_handlers ();
reactor.run_reactor_event_loop (tv);
// only the timer should have fired
if (handler.dispatch_order_ != 2)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("Incorrect number fired %d\n"),
handler.dispatch_order_));
ok_to_go = false;
}
// Reset the dispatch_order_ count and schedule another timer
handler.dispatch_order_ = 1;
if (-1 == reactor.schedule_timer (&handler,
0,
ACE_Time_Value (0)))
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("schedule_timer")));
ok_to_go = false;
}
// Resume the handlers - things should work now
reactor.resume_handlers ();
if (ok_to_go)
{
reactor.run_reactor_event_loop (tv);
}
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 ("remover_handler pipe")));
if (handler.dispatch_order_ != 4)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("Incorrect number fired %d\n"),
handler.dispatch_order_));
ok_to_go = false;
}
return ok_to_go;
}
示例13: reac
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
if (parse_args (argc, argv) == -1)
return -1;
ACE_Select_Reactor sr;
ACE_Reactor reac (&sr);
ACE_Reactor::instance (&reac);
ACE_SOCK_Stream stream[iter];
ACE_SOCK_Connector connector[iter];
Purging_Handler ph[iter];
ACE_INET_Addr addr (port,
host);
ACE_Reactor *singleton =
ACE_Reactor::instance ();
for (int i = 0; i != iter; ++i)
{
if (connector[i].connect (stream[i],
addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"Error while connecting: %p\n",
"client"),
-1);
if (stream[i].get_handle () == ACE_INVALID_HANDLE)
ACE_ERROR_RETURN ((LM_ERROR,
"Got invalid handles after connecting the [%d] time\n",i),
-1);
if (singleton->register_handler (stream[i].get_handle (),
&ph[i],
ACE_Event_Handler::READ_MASK) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
"Registration failed\n"),
-1);
// ACE_Time_Value tv (1);
// while (singleton->handle_events (&tv) >= 1);
}
// Handle events moved to here to prevent this test taking best part
// of a minute
ACE_Time_Value tv (3);
while (singleton->handle_events (&tv) >= 1)
{
// No action.
}
// Remove the handlers to avoid the possibility of the reactor
// using any of them after they leave the scope (those that haven't
// been closed and removed already, that is).
for (int j = 0; j != iter; ++j)
{
singleton->remove_handler (stream[j].get_handle (),
ACE_Event_Handler::READ_MASK);
}
if ((iter - purged_handles) > 20)
ACE_ERROR_RETURN ((LM_ERROR,
"(%P|%t) Purging hasnt worked at all\n"),
-1);
return 0;
}