ACE之ACE_Reactor_Notify

简介

ACE_Reactor_Notify作为Reactor的实现类ACE_Reactor_Impl内部通知来唤醒eventloop

抽象

«abstract»
ACE_Reactor_Notify
+int open(ACE_Reactor_Impl *,ACE_Timer_Queue *timer_queue = 0,int disable_notify = 0)
+int close(void)
+nt notify(ACE_Event_Handler *eh = 0,ACE_Reactor_Mask mask = ACE_Event_Handler::EXCEPT_MASK,ACE_Time_Value *timeout = 0)
+int dispatch_notifications(int &number_of_active_handles,ACE_Handle_Set &rd_mask)
+ACE_HANDLE notify_handle(void)
+int is_dispatchable(ACE_Notification_Buffer &buffer)
+int dispatch_notify(ACE_Notification_Buffer &buffer)
+int read_notify_pipe(ACE_HANDLE handle,ACE_Notification_Buffer &buffer)
+void max_notify_iterations(int)
+int max_notify_iterations(void)
+int purge_pending_notifications(ACE_Event_Handler * = 0,ACE_Reactor_Mask = ACE_Event_Handler::ALL_EVENTS_MASK)
ACE_Notification_Buffer
- ACE_Event_Handler *eh_
- ACE_Reactor_Mask mask_
ACE_Event_Handler

ACE_Notification_Buffer:作为缓存,连接调用线程和reactor线程

实现

不同的io复用机制有不同的实现

ACE_Reactor_Notify
ACE_Dev_Poll_Reactor_Notify
ACE_Select_Reactor_Notify
ACE_WFMO_Reactor_Notify

ACE_Dev_Poll_Reactor_Notify:是epoll和devpoll的实现
ACE_Select_Reactor_Notify:是select的实现
ACE_WFMO_Reactor_Notify:是windows平台wfmo的实现

ACE_Dev_Poll_Reactor_Notify

ACE_Dev_Poll_Reactor_Notify
# ACE_Dev_Poll_Reactor *dp_reactor_
# ACE_Pipe notification_pipe_
# int max_notify_iterations_
# ACE_Notification_Queue notification_queue_

open

  • 赋值dp_reactor_
  • 开启管道notification_pipe_,并且设置管道读写端的属性close-on-exec
  • 开启通道队列notification_queue_,预分配内存,设置管道的读写端属性非阻塞

close

  • 管道notification_pipe_预分配内存的释放
  • 管道关闭

notify:对于开启了队列的通过事件处理器以及事件类型构造ACE_Notification_Buffer添加到管道队列中,向管道写端写入数据唤醒读端,没有开启队列的直接向管道写端写入数据
dispatch_notifications:不做任何操作
notify_handle:管道的读端句柄
is_dispatchable:不做任何操作
dispatch_notify:根据ACE_Notification_Buffer的事件类型调用handler的指定方法
read_notify_pipe:对于开启了队列,从队列中取出ACE_Notification_Buffer,如果队列中还有,则向写端写入数据唤醒读端;对于 没有开启队列,直接从管道读取
purge_pending_notifications:对于开启管道队列的,清空管道队列中未处理的数据

ACE_Select_Reactor_Notify

ACE_Select_Reactor_Notify
# ACE_Select_Reactor_Impl *select_reactor_
# ACE_Pipe notification_pipe_
# int max_notify_iterations_
# ACE_Notification_Queue notification_queue_

数据成员与ACE_Dev_Poll_Reactor_Notify类似,方法说明就不细说
open:差异将管道读端句柄添加到select_reactor_中,而ACE_Dev_Poll_Reactor_Notify是在ACE_Dev_Poll_Reactoropen时添加到reactor中
dispatch_notifications:如果rd_mask句柄集中包含管道的句柄,则事件数减小,清除句柄集中管道句柄,调用handle_input
dispatch_notify:对于开启了队列的,从队列中取出数据,如果队列中还有数据,则向写端写数据唤醒读端
is_dispatchable:检查ACE_Notification_Buffer是否有事件处理器

ACE_WFMO_Reactor_Notify

ACE_WFMO_Reactor_Notify
- ACE_Timer_Queue *timer_queue_
- ACE_Auto_Event wakeup_one_thread_
- ACE_Message_Queue<ACE_MT_SYNCH> message_queue_
- int max_notify_iterations_
-int handle_signal(int signum, siginfo_t * = 0, ucontext_t * = 0)

open:注册到wfmo_reactor
dispatch_notifications:不做任何操作
get_handlewakeup_one_thread_的句柄
dispatch_notify:不做任何操作
read_notify_pipe:不做任何操作
notify:向message_queue_队列中添加数据,使用wakeup_one_thread_唤醒
handle_signal:从队列中取出事件作处理

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kgduu

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值