当前位置: 首页 > article >正文

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:从队列中取出事件作处理


http://www.kler.cn/news/304273.html

相关文章:

  • IHostedLifecycleService是如何管理后台任务的
  • linux-L3_linux 查看进程(node-red)
  • 如何防止ZIP压缩文件被随意打开?
  • union和union all的区别,别再傻傻分不清楚了!
  • 多模态学习
  • 算法练习题20——猴子选大王(模拟)
  • 【鸿蒙】HarmonyOS NEXT星河入门到实战9-组件化开发进阶应用状态管理
  • [SC]Windows VS2022下配置SystemC环境
  • web前端-HTML常用标签(三)
  • 揭秘线程安全:HashMap 的四大实用策略
  • 树莓派智能语音助手实现音乐播放
  • ​经​纬​恒​润​二​面​​三​七​互​娱​一​面​​元​象​二​面​
  • 海鸥相机存储卡格式化如何恢复数据
  • 工作流技术(WorkFlow)
  • 【系统规划与管理师】【案例分析】【考点】【答案篇】第5章 IT服务部署实施
  • 主机加固的案例应用
  • 前端计算机网络面试基础知识
  • rancker 图形化界面
  • 充电管理芯片
  • Redis简介、常用命令及优化
  • 串口通信协议
  • python如何把数据导出生成excel ?
  • Python 数学建模——假设检验
  • 学习之性能的理论知识一
  • 【中国国际航空-注册/登录安全分析报告】
  • Spring Cloud集成Eurake
  • 《PneumoLLM:利用大型语言模型的力量进行尘肺病诊断》|文献速递--基于深度学习的医学影像病灶分割
  • mysql笔记4(数据类型)
  • Nginx 实现会话保持的方式配置
  • echarts饼图让部分数据显示在图外,部分显示在图内