class CMyReactor : public ACE_Dev_Poll_Reactor
{
....
//重载内部注册回调的接口
int register_handler_i (ACE_HANDLE handle,ACE_Event_Handler *eh,ACE_Reactor_Mask mask)
{
ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler_i");
if (handle == ACE_INVALID_HANDLE
|| mask == ACE_Event_Handler::NULL_MASK)
{
errno = EINVAL;
return -1;
}
if (this->handler_rep_.find (handle) == 0)
{
// Handler not present in the repository. Bind it.
if (this->handler_rep_.bind (handle, event_handler, mask) != 0)
return -1;
struct epoll_event epev;
ACE_OS::memset (&epev, 0, sizeof (epev));
static const int op = EPOLL_CTL_ADD;
epev.events = this->reactor_mask_to_poll_event (mask);
epev.data.fd = handle;
if( NET_SETTING.ET_MODE )
{
epev.events |= EPOLLET; // 关键代码,增加ET标识 [1/13/2011 yao]
}
if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1)
{
ACE_ERROR ((LM_ERROR, "%p\n", "epoll_ctl"));
(void) this->handler_rep_.unbind (handle);
return -1;
}
}
else
{
// Handler is already present in the repository, so register it
// again, possibly for different event. Add new mask to the
// current one.
if (this->mask_ops_i (handle, mask, ACE_Reactor::ADD_MASK) == -1)
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mask_ops_i"), -1);
}
// Note the fact that we've changed the state of the wait_set_,
// which is used by the dispatching loop to determine whether it can
// keep going or if it needs to reconsult select().
// this->state_changed_ = 1;
return 0;
}
....
}
ACE PROACTOR EPOLL ET模式
最新推荐文章于 2018-03-19 22:07:00 发布