本文整理汇总了C++中reactor函数的典型用法代码示例。如果您正苦于以下问题:C++ reactor函数的具体用法?C++ reactor怎么用?C++ reactor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reactor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: conf
bool CoAPRDService::initialize()
{
try
{
std::string conf("service.conf");
std::string reactor("service.reactor");
_confPtr = ServiceGetter::findByName<ConfService>(context(), conf);
_reactorPtr = ServiceGetter::findByName<ReactorService>(context(), reactor);
}
catch(toolkit::NullPointerException &e)
{
ACE_DEBUG((LM_DEBUG, "get service failed at SerialPortService\n"));
return false;
}
_coapWrapperPtr = new CoAPWrapper();
if (_coapWrapperPtr->Create(_confPtr->_rdAddr,
_confPtr->_rdAddrPort,
_confPtr->_coapDebugLevel
) < 0)
{
ACE_DEBUG((LM_DEBUG,"Failed to create coap\n"));
return false;
}
_rdRes = new CoAP_RD_Resource(_coapWrapperPtr.get());
if ((_rdRes->Create()) == 0)
{
ACE_DEBUG((LM_DEBUG,"Failed to craete rd resource\n"));
return false;
}
_rdLookup = new CoAPRDLookUpResource(_coapWrapperPtr.get());
if ((_rdLookup->Create()) == 0)
{
ACE_DEBUG((LM_DEBUG,"Failed to craete lookup resource\n"));
return false;
}
ACE_Time_Value timeout;
timeout.sec(5);
_reactorPtr->register_handler(this, ACE_Event_Handler::READ_MASK);
_reactorPtr->schedule_timer(this, 0, timeout);
return true;
}
示例2: Quit_Handler
Quit_Handler (ACE_Reactor *r) : ACE_Event_Handler (r) {
SetConsoleMode (ACE_STDIN, ENABLE_LINE_INPUT
| ENABLE_ECHO_INPUT
| ENABLE_PROCESSED_INPUT);
if (reactor ()->register_handler
(this, quit_seen_.handle ()) == -1
|| ACE_Event_Handler::register_stdin_handler
(this, r, ACE_Thread_Manager::instance ()) == -1)
r->end_reactor_event_loop ();
}
示例3: ACE_UNUSED_ARG
int TCPConnectionHandler::handle_output (ACE_HANDLE handle)
{
ACE_UNUSED_ARG (handle);
if (!buffers_)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("TCPConnectionHandler::handle_output call for empty buffers (%d)\n"), handle));
if (0 > sendBuffers ()) // socket broken, kill yourself
return -1;
if (!buffers_) // everything already send, unregister
{
reactor ()->cancel_wakeup (this,
ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::DONT_CALL);
reactor ()->remove_handler (this,
ACE_Event_Handler::WRITE_MASK | ACE_Event_Handler::DONT_CALL);
}
return 0;
}
示例4: logError
bool
OpenDDS::DCPS::ReliableMulticast::detail::ReactivePacketSender::open(
)
{
if (socket_.ACE_SOCK_Dgram::open(
local_address_
) == -1)
{
logError("ReactivePacketSender: failure to open\n");
return false;
}
ACE_INET_Addr address;
if (this->socket_.get_local_addr (address) != 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("(%P|%t) ERROR: ReliableMulticast::open_socket ")
ACE_TEXT ("- %p"),
ACE_TEXT ("cannot get local addr\n")),
false);
}
this->local_address_.set_port_number (address.get_port_number ());
if (reactor()->register_handler(
this,
ACE_Event_Handler::READ_MASK
) == -1)
{
logError("ReactivePacketSender: failure to register_handler\n");
return false;
}
if (reactor()->schedule_timer(
this,
0,
ACE_Time_Value(1),
ACE_Time_Value(1)
) == -1)
{
logError("ReactivePacketSender: failure to schedule_timer\n");
}
return true;
}
示例5: ACE_Message_Block
int AC_Input_Handler::close (u_long) {
ACE_Message_Block *shutdown_message = 0;
ACE_NEW_RETURN
(shutdown_message,
ACE_Message_Block (0, ACE_Message_Block::MB_STOP), -1);
output_handler_->put (shutdown_message);
reactor ()->remove_handler
(connected_clients_, ACE_Event_Handler::READ_MASK);
return output_handler_->wait ();
}
示例6: reactor
int KSG_Service_Handler::release()
{
if(curr_blk_)
{
// 当接收数据一半的时候关闭连接,则需要释放资源
curr_blk_->release();
curr_blk_ = NULL;
}
reactor()->cancel_timer(this);
//reactor()->remove_handler(this,ACE_Event_Handler::ALL_EVENTS_MASK);
return 0;
}
示例7: ACE_UNUSED_ARG
int
Stop_Handler::handle_input (ACE_HANDLE handle)
{
ACE_UNUSED_ARG (handle);
ACE_DEBUG ((LM_INFO,
ACE_TEXT ("(%P|%t) Stop_Handler::handle_input - entered\n")));
for (size_t i = 0; i < HANDLERS_TO_STOP_TABLE_SIZE; ++i)
{
// remove from the reactor's tables all non-null entries
if (this->handlers_to_stop_[i])
{
#if defined ACE_HAS_EXCEPTIONS
// protect from deleted pointer
try
{
#endif // ACE_HAS_EXCEPTIONS
this->reactor ()->cancel_timer (this->handlers_to_stop_[i]);
this->reactor ()->remove_handler
(this->handlers_to_stop_[i],
ACE_Event_Handler::ALL_EVENTS_MASK
| ACE_Event_Handler::DONT_CALL);
#if defined ACE_HAS_EXCEPTIONS
}
catch (...)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("(%P|%t) Stop_Handler::handle_input - ")
ACE_TEXT ("EXCEPTION CATCHED. Most probably ")
ACE_TEXT ("handler's pointer has been deleted.\n")));
}
#endif // ACE_HAS_EXCEPTIONS
this->handlers_to_stop_[i] = 0;
}
}
this->reactor ()->remove_handler (this->registered_signals_);
if (reactor ()->end_reactor_event_loop () == -1)
{
ACE_ERROR_RETURN ((LM_DEBUG,
ACE_TEXT ("(%P|%t) Stop_Handler::handle_signal:%p\n"),
ACE_TEXT ("end_reactor_event_loop")),
-1);
}
ACE_DEBUG ((LM_INFO,
ACE_TEXT ("(%P|%t) Stop_Handler::handle_input - completed.\n")));
return 0;
}
示例8: reactor
void P2pEndpoint::close()
{
const ACE_Reactor_Mask masks = ACE_Event_Handler::ALL_EVENTS_MASK |
ACE_Event_Handler::DONT_CALL;
reactor()->remove_handler(this, masks);
clearAddresses();
if (isOpened()) {
udp_->close();
NSRPC_LOG_DEBUG(ACE_TEXT("UDP socket closed"));
}
}
示例9: TCPConnectionHandler
int TCPAcceptorHandler::make_svc_handler (TCPConnectionHandler *& sh)
{
sh = new TCPConnectionHandler (true);
sh->reactor (reactor ());
if (handlersRegister_->TCPServersNo () >= HandlersNo)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("TCPAcceptorHandler::make_svc_handler called to many times!\n")));
else
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("TCPAcceptorHandler::make_svc_handler new TCP server created\n")));
return 0;
}
示例10: reschedule
int Logging_Event_Handler_Ex::open () {
int result = PARENT::open ();
if (result != -1) {
ACE_Time_Value reschedule (max_client_timeout_.sec () / 4);
result =
reactor ()->schedule_timer
(this,
0,
max_client_timeout_, // Initial timeout.
reschedule); // Subsequent timeouts.
}
return result;
}
示例11: schedp_
ReactorTask::ReactorTask(ACE_Sched_Params *pschedp,
bool shutdownOnException,
int size) :
schedp_(ACE_SCHED_OTHER, 0),
reactor_(),
shutdownOnException_(shutdownOnException)
{
MIRO_LOG_CTOR("Miro::ReactorTask");
reactor(&reactor_);
reactor_.open(size);
if (pschedp)
schedp_ = (*pschedp);
}
示例12: get_peer
ACE_INT32 Handle_data::open( )
{
ACE_INT32 ret = 0;
ACE_INET_Addr remote_addr;
get_peer().get_remote_addr( remote_addr );
ACE_DEBUG( (LM_DEBUG, "the remote addr is %s\n", remote_addr.get_host_addr()) );
ret = reactor()->register_handler( this, ACE_Event_Handler::READ_MASK );
if (ret != -1)
{
ACE_DEBUG( (LM_DEBUG, "handle data register ok!\n") );
}
return ret;
}
示例13: ACE_NEW_RETURN
int Logging_Acceptor::handle_input(ACE_HANDLE)
{
Logging_Event_Handler *peer_handler = 0;
ACE_NEW_RETURN(peer_handler, Logging_Event_Handler(reactor()), -1);
if (acceptor_.accept(peer_handler->peer()) == -1) {
delete peer_handler;
return -1;
} else if (peer_handler->open() == -1) {
peer_handler->handle_close();
return -1;
}
return 0;
}
示例14: ACE_DEBUG
int KSG_Service_Handler::handle_timeout(const ACE_Time_Value ¤t_time, const void *act )
{
if(current_time - this->request_time_ >= max_client_timeout_
|| current_time - this->connect_time_ >= max_client_timeout_)
{
ACE_DEBUG((LM_INFO,"连接超时,关闭连接..."));
reactor()->remove_handler(this,ACE_Event_Handler::ALL_EVENTS_MASK|ACE_Event_Handler::DONT_CALL);
//reactor()->notify(this);
closed_ = 1;
return -1;
}
return 0;
}
示例15: reactor
int Ogre_TCPAccept_Hdl::handle_close ()
{
//
if (peer_acceptor_.get_handle () != ZCE_INVALID_SOCKET)
{
reactor()->remove_handler (this, true);
peer_acceptor_.close ();
}
//删除自己
delete this;
return 0;
}