ACE_Select_Reactor_T 介绍 (2)
本章目录
2. ACE_Select_Reactor_T 介绍
该类继承自类ACE_Select_Reactor_Impl,实现了对IO时间、信号量、定时器的分发处理,公共的函数需要ACE_Reactor_Token进行锁定。typedef ACE_Select_Reactor_T<ACE_Select_Reactor_Token> ACE_Select_Reactor定义了常用的ACE_Select_Reactor类,可以在程序中直接使用。
2.2. 类协作图
ACE_Select_Reactor 核心交互图,表明了 ACE_Select_Reactor 针对 Socket/IO, 定时器,通知和信号量的整体数据结构。
2.3. 类主要成员变量
ACE_Select_Reactor_Impl继承自 ACE_Reactor_Impl,在类ACE_Select_Reactor_Impl中定义了常用的成员变量:
ace/Select_Reactor_Base.h
1 |
/// 提供<ACE_HANDLE>到<ACE_Event_Handler *>的映射 |
注解
其中ACE_Select_Reactor_Handler_Repository handler_rep_的数据结构定义,可参见 bind 函数 。
2.4. 事件处理函数调用图
注解
calculate_timeout 函数的调用为类实现中 timer_queue_ 时间队列中最早到期时间,以便设置后续 select 调用函数的超时时间,从而实现了时间队列与IO句柄触发的整合。
2.5. 事件处理主流程
ace/Reactor.cpp
1 |
int |
行12行,Reactor调用了其实现者的 handle_events(ACE_Time_Value *max_wait_time) 函数,实现类的handle_event函数承担了主要工作的分发和处理。
2.5.1. handle_events 函数流程
ace/Select_Reactor_T.cpp handle_events 函数
1 |
template <class ACE_SELECT_REACTOR_TOKEN> int |
2.5.2. handle_events_i 函数流程
ace/Select_Reactor_T.cpp handle_events_i 函数
1 |
template <class ACE_SELECT_REACTOR_TOKEN> int |
行18, this->wait_for_multiple_events (this->dispatch_set_,max_wait_time) 实现了对于可分发句柄集的获取。
行21,this->dispatch (number_of_active_handles,this->dispatch_set_) 实现了对于分发句柄集的处理。
2.5.2.1. wait_for_multiple_events 函数
ace/Select_Reactor_T.cpp wait_for_multiple_events 函数
1 |
// Must be called with lock held. template <class ACE_SELECT_REACTOR_TOKEN> int |
行12,,this->any_ready(dispatch_set) 实现了获取不需要select函数触发的其他类型满足触发条件的句柄
行25-26,this->timer_queue_->calculate_timeout(max_wait_time,&timer_buf) 实现了对定时器队列的超时的计算
行38-42,ACE_OS::select(width,dispatch_set.rd_mask_,dispatch_set.wr_mask_,dispatch_set.ex_mask_,this_timeout) 实现了对使用select函数返回的已触发的handle的跟踪
2.5.2.2. dispatch 函数
ace/Select_Reactor_T.cpp dispatch 函数
1 |
template <class ACE_SELECT_REACTOR_TOKEN> int |
处理顺序:
- dispatch_timer_handlers 处理分发定时器,定时器的处理优于Socket/IO的处理。 展开流程见: 定时器与Select_Reactor的分发集成。
- dispatch_notification_handlers 处理分发通知类消息。展开流程见: 通知与Select_Reactor 的分发集成。
- dispatch_io_handlers 处理分发 io handlers。展开流程见: IO句柄与Select_Reactor的分发集成。
ACE_Select_Reactor_T 介绍 (2)的更多相关文章
- ACE Reactor 源码解析
http://blogs.readthedocs.org/ ACE的学习笔记,根据源码分析了Reactor模型的实现. 因为笔记编写技术限制,这里仅列出主要目录,如有可能可以抽空复制到该Blog中 ...
- CSS3 background-image背景图片相关介绍
这里将会介绍如何通过background-image设置背景图片,以及背景图片的平铺.拉伸.偏移.设置大小等操作. 1. 背景图片样式分类 CSS中设置元素背景图片及其背景图片样式的属性主要以下几个: ...
- MySQL高级知识- MySQL的架构介绍
[TOC] 1.MySQL 简介 概述 MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle公司. MySQL是一种关联数据库管理系统,将数据保存在不同的表中,而 ...
- Windows Server 2012 NIC Teaming介绍及注意事项
Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...
- Linux下服务器端开发流程及相关工具介绍(C++)
去年刚毕业来公司后,做为新人,发现很多东西都没有文档,各种工具和地址都是口口相传的,而且很多时候都是不知道有哪些工具可以使用,所以当时就想把自己接触到的这些东西记录下来,为后来者提供参考,相当于一个路 ...
- JavaScript var关键字、变量的状态、异常处理、命名规范等介绍
本篇主要介绍var关键字.变量的undefined和null状态.异常处理.命名规范. 目录 1. var 关键字:介绍var关键字的使用. 2. 变量的状态:介绍变量的未定义.已定义未赋值.已定义已 ...
- HTML DOM 介绍
本篇主要介绍DOM内容.DOM 节点.节点属性以及获取HTML元素的方法. 目录 1. 介绍 DOM:介绍DOM,以及对DOM分类和功能的说明. 2. DOM 节点:介绍DOM节点分类和节点层次. 3 ...
- HTML 事件(一) 事件的介绍
本篇主要介绍HTML中的事件知识:事件相关术语.DOM事件规范.事件对象. 其他事件文章 1. HTML 事件(一) 事件的介绍 2. HTML 事件(二) 事件的注册与注销 3. HTML 事件(三 ...
- HTML5 介绍
本篇主要介绍HTML5规范的内容和页面上的架构变动. 目录 1. HTML5介绍 1.1 介绍 1.2 内容 1.3 浏览器支持情况 2. 创建HTML5页面 2.1 <!DOCTYPE> ...
随机推荐
- 2018.10.6 Hibernate配置文件详解-------ORM元数据配置 &&& hibernate主配置文件
ORM既然是实体与关系数据库的映射,那就需要建立实体和关系数据库之间的基础数据,也可以称为元数据.简单的说就是表示类与表.列与属性(get.set方法)等等之间对应关系的数据. Customer.hb ...
- 关于TOCTTOU攻击的简介
前言 最近看到了一些以 at 结尾的Linux系统调用,在维基百科上面说这可以防御一些特定的TOCTTOU攻击,而在TOCTTOU对应页面中并没有中文版的介绍,而且百度的结果也比较少,于是决定抽空写一 ...
- Spring Boot 推荐的基础 POM 文件
名称 说明 spring-boot-starter 核心 POM,包含自动配置支持.日志库和对 YAML 配置文件的支持. spring-boot-starter-amqp 通过 spring-rab ...
- normal 普通身份 sysdba 系统管理员身份 sysoper 系统操作员身份 dba和sysdba
as sysdba 就是以sysdba登录,oracle登录身份有三种:normal 普通身份sysdba 系统管理员身份sysoper 系统操作员身份每种身份对应不同的权限 sysdba权限:●启动 ...
- Redis-cluster详解
redis集群结构 特点: 1 所有redis节点(包括主和从)彼此互联(两两通信),底层使用内部的二进制传输协议,优化传输速度;(所有功能特点的基础) 2 集群中也有主从,也有高可用的 ...
- spring入门学习感悟
1:ioc:控制反转 控制权的转移,应用程序本身不负责依赖对象的创建和维护,而是有外部容器负责创建和维护的(获取依赖对象的过程被反转了) 2:di:依赖注入,它是一种控制反转的一种实现方法,ioc容器 ...
- js bind的实现
call,apply,bind都是用来挟持对象或者说更改this指向的,但是区别还是有的,call 传参是 fn.call(this,1,2,3) apply传参是 fn.apply(this,[1, ...
- 解方程(hash,秦九韶算法)
题目描述 已知多项式方程: a0+a1x+a2x2+⋯+anxn=0 求这个方程在 [1,m]内的整数解(n 和 m 均为正整数). 输入输出格式 输入格式: 共 n+2 行. 第一行包含 2个整数 ...
- 蚯蚓(noip2016,贪心,单调性)
题目描述 本题中,我们将用符号⌊c⌋ 表示对 c 向下取整,例如:⌊3.0⌋=⌊3.1⌋=⌊3.9⌋=3 . 蛐蛐国最近蚯蚓成灾了!隔壁跳蚤国的跳蚤也拿蚯蚓们没办法,蛐蛐国王只好去请神刀手来帮他们消灭 ...
- Python3集成安装xadmin
Python3集成安装xadmin1:创建虚拟环境C:\Users\Adminstrator>mkvirtualenv -p C:\Python34\python.exe MyDjango如果提 ...