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

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.lryc.cn/news/443147.html

相关文章:

  • 【小沐学GIS】blender导入OpenStreetMap城市建筑(blender-osm、blosm)
  • 数字IC设计\FPGA 职位经典笔试面试整理--语法篇 Verilog System Verilog(部分)
  • 【EtherCAT】CiA402简介
  • 嵌入式Linux:模块化编程
  • 【两方演化博弈代码复现】:双方演化博弈的原理、概率博弈仿真、相位图、单个参数灵敏度演化
  • Selenium打开浏览器后闪退问题解决
  • 【图论】最短路应用
  • Spring Boot实战:使用策略模式优化商品推荐系统
  • Navicat导入Sql文件至Mysql数据库,事务失效
  • 篮球运动场景物体检测系统源码分享
  • Docker实操:安装MySQL5.7详解(保姆级教程)
  • git reflog
  • 使用 Vue 3 和 TypeScript 实现带打字效果的仿 AI 分析展示组件
  • 数据清洗-缺失值填充-K-NN算法(K-Nearest Neighbors, K-NN算法)
  • 爬虫----webpack
  • Spring Mybatis PageHelper分页插件 总结
  • 9、等保测评介绍
  • 解决Gson将长数字( json字符串)转换为科学记数法格式
  • php环境搭建教程
  • 测试ASP.NET Core的WebApi项目调用WebService
  • 【用Java学习数据结构系列】对象的比较(Priority Queue实现的前提)
  • 快手视频怎么保存到相册?(详细操作)
  • 为什么 ECB 模式不安全
  • 『功能项目』事件中心处理怪物死亡【55】
  • 一个安卓鸿蒙化工具
  • PyQt5库学习之QFileDialog.getExistingDirectory函数
  • AUTOSAR_EXP_ARAComAPI的5章笔记(9)
  • 京东-第2题-撞车
  • Vue3流程图插件-Vue Flow
  • 初始网络编程(下)