ACE之Proactor框架

简介

Proactor使用的是异步io,其实现与Reactor相似,也使用桥接模式
ACE_Proactor 对ACE_Proactor_Impl
ACE_Asynch_Operation对ACE_Asynch_Operation_Impl
ACE_Asynch_Result对ACE_Asynch_Result_Impl

组成

ACE_Proactor
ACE_Proactor_Impl
ACE_Asynch_Read_Or_WriteXXX_Impl
ACE_Asynch_Read_Or_WriteXXX_Result_Impl
ACE_Handler

ACE_Handler

异步的处理类

ACE_Handler
# ACE_Proactor *proactor_
# ACE_HANDLE handle_
# ACE_Refcounted_Auto_Ptr<Proxy, ACE_SYNCH_MUTEX> proxy_
+void handle_read_stream(const ACE_Asynch_Read_Stream::Result &result)
+void handle_write_dgram(const ACE_Asynch_Write_Dgram::Result &result)
+void handle_read_dgram(const ACE_Asynch_Read_Dgram::Result &result)
+void handle_write_stream(const ACE_Asynch_Write_Stream::Result &result)
+void handle_read_file(const ACE_Asynch_Read_File::Result &result)
+void handle_write_file(const ACE_Asynch_Write_File::Result &result)
+void handle_accept(const ACE_Asynch_Accept::Result &result)
+void handle_connect(const ACE_Asynch_Connect::Result &result)
+void handle_transmit_file(const ACE_Asynch_Transmit_File::Result &result)
+void handle_time_out(const ACE_Time_Value &tv,const void *act = 0)
+void handle_wakeup(void)
+ACE_Proactor *proactor(void)
+void proactor(ACE_Proactor *p)
+ACE_HANDLE handle(void)
+void handle(ACE_HANDLE)
+Proxy_Ptr &proxy(void)
ACE_Service_Handler
+void open(ACE_HANDLE new_handle,ACE_Message_Block &message_block)
+void addresses(const ACE_INET_Addr &remote_address, const ACE_INET_Addr &local_address)
Proxy
- ACE_Handler *handler_
+ACE_Handler *handler(void)

ACE_Service_Handler:在ACE_Handler 基础上添加了open方法,子类继承ACE_Service_Handler主要是向Proactor注册

ACE_Asynch_Result

异步处理结果

ACE_Asynch_Result
# ACE_Asynch_Result_Impl *implementation_
+size_t bytes_transferred(void)
+const void *act(void)
+int success(void)
+const void *completion_key(void)
+unsigned long error(void)
+ACE_HANDLE event(void)
+unsigned long offset(void)
+unsigned long offset_high(void)
+int priority(void)
+int signal_number(void)
#ACE_Asynch_Result_Impl *implementation(void)
ACE_Asynch_Result_Impl

ACE_Asynch_Result_Impl :增加了completepost_completion,在具体操作执行时,创建对应的结果对象,将操作中的Handler和handle传到结果中

ACE_Asynch_Operation

异步操作

ACE_Asynch_Operation
+int open(ACE_Handler &handler,ACE_HANDLE handle,const void *completion_key,ACE_Proactor *proactor)
+int cancel(void)
+ACE_Proactor* proactor(void)
#virtual ACE_Asynch_Operation_Impl *implementation(void)
ACE_Asynch_Operation_Impl

ACE_Asynch_Operation_Impl

异步操作实现抽象类的子类

ACE_Asynch_Operation_Impl
+int open(const ACE_Handler::Proxy_Ptr &handler_proxy,ACE_HANDLE handle,const void *completion_key,ACE_Proactor *proactor)
+int cancel(void)
+ACE_Proactor* proactor(void)
ACE_Asynch_Read_Stream_Impl
ACE_Asynch_Write_Stream_Impl
ACE_Asynch_Read_File_Impl
ACE_Asynch_Write_File_Impl
ACE_Asynch_Accept_Impl
ACE_Asynch_Connect_Impl
ACE_Asynch_Transmit_File_Impl
ACE_Asynch_Read_Dgram_Impl
ACE_Asynch_Write_Dgram_Impl

ACE_Asynch_Read_Stream_Impl:在基类基础上添加了readreadv
ACE_Asynch_Write_Stream_Impl :在基类基础上添加了writewritev
ACE_Asynch_Read_File_Impl:在ACE_Asynch_Read_Stream_Impl基础上添加了readreadv
ACE_Asynch_Write_File_Impl:在ACE_Asynch_Write_Stream_Impl 基础上添加了writewritev
ACE_Asynch_Accept_Impl:在基类基础上添加了accept
ACE_Asynch_Connect_Impl:在基类基础上添加了connect
ACE_Asynch_Transmit_File_Impl :在基类基础上添加了transmit_file
ACE_Asynch_Read_Dgram_Impl :在基类基础上添加了recv
ACE_Asynch_Write_Dgram_Impl:在基类基础上添加了send

ACE_Asynch_Result_Impl

ACE_Asynch_Result_Impl
ACE_Asynch_Read_Stream_Result_Impl
ACE_Asynch_Write_Stream_Result_Impl
ACE_Asynch_Read_File_Result_Impl
ACE_Asynch_Write_File_Result_Impl
ACE_Asynch_Accept_Result_Impl
ACE_Asynch_Connect_Result_Impl
ACE_Asynch_Transmit_File_Result_Impl
ACE_Asynch_Read_Dgram_Result_Impl
ACE_Asynch_Write_Dgram_Result_Impl

ACE_Asynch_Read_Stream_Result_Impl:增加了bytes_to_read,message_block,handle
ACE_Asynch_Write_Stream_Result_Impl:增加了bytes_to_write,message_block,handle
ACE_Asynch_Accept_Result_Impl:增加了bytes_to_read,message_block, listen_handle,accept_handle
ACE_Asynch_Connect_Result_Impl:增加了connect_handle
ACE_Asynch_Transmit_File_Result_Impl:增加了socket,file,header_and_trailer,bytes_to_write,bytes_per_sendflags
ACE_Asynch_Read_Dgram_Result_Impl:增加了message_block,bytes_to_read,remote_address,flagshandle
ACE_Asynch_Write_Dgram_Result_Impl:增加了message_block,bytes_to_write,flagshandle

ACE_Proactor_Impl的实现类

«interface»
ACE_Proactor_Impl
ACE_WIN32_Proactor
ACE_POSIX_Proactor
ACE_POSIX_AIOCB_Proactor
ACE_POSIX_SIG_Proactor
ACE_POSIX_CB_Proactor
ACE_SUN_Proactor

异步类

异步操作子类

ACE_Asynch_Read_Stream
ACE_Asynch_Write_Stream
ACE_Asynch_Read_File
ACE_Asynch_Write_File
ACE_Asynch_Accept
ACE_Asynch_Operation
ACE_Asynch_Connect
ACE_Asynch_Transmit_File
ACE_Asynch_Read_Dgram
ACE_Asynch_Write_Dgram

异步结果类

ACE_Asynch_Result
# ACE_Async_Result_Impl *implementation_
ACE_Asynch_Read_Stream::Result
# ACE_Async_Read_Stream_Result_Impl *implementation_
ACE_Asynch_Write_Stream::Result
# ACE_Async_Write_Stream_Result_Impl *implementation_
ACE_Asynch_Read_File::Result
# ACE_Async_Read_File_Result_Impl *implementation_
ACE_Asynch_Write_File::Result
# ACE_Async_Write_File_Result_Impl *implementation_
ACE_Asynch_Accept::Result
# ACE_Async_Accept_Result_Impl *implementation_
ACE_Asynch_Connect::Result
# ACE_Async_Connect_Result_Impl *implementation_
ACE_Asynch_Transmit_File::Result
# ACE_Async_Transmit_File_Result_Impl *implementation_
ACE_Asynch_Read_Dgram::Result
# ACE_Async_Read_Dgram_Result_Impl *implementation_
ACE_Asynch_Write_Dgram::Result
# ACE_Async_Write_Dgram_Result_Impl *implementation_

win32异步操作实现类子类

ACE_WIN32_Asynch_Operation
# ACE_WIN32_Proactor *win32_proactor_
# ACE_Proactor *proactor_
# ACE_Handler::Proxy_Ptr handler_proxy_
# ACE_HANDLE handle_
ACE_Asynch_Operation_Impl
ACE_WIN32_Asynch_Read_Stream
ACE_Asynch_Read_Stream_Impl
ACE_WIN32_Asynch_Write_Stream
ACE_Asynch_Write_Stream_Impl
ACE_Asynch_Read_File_Impl
ACE_WIN32_Asynch_Read_File
ACE_Asynch_Write_File_Impl
ACE_WIN32_Asynch_Write_File
ACE_Asynch_Accept_Impl
ACE_WIN32_Asynch_Accept
ACE_Asynch_Connect_Impl
ACE_WIN32_Asynch_Connect
ACE_Asynch_Transmit_File_Impl
ACE_WIN32_Asynch_Transmit_File
ACE_Asynch_Read_Dgram_Impl
ACE_WIN32_Asynch_Read_Dgram
ACE_Asynch_Write_Dgram_Impl
ACE_WIN32_Asynch_Write_Dgram

ACE_WIN32_Asynch_Operation :包含了处理器,所属的Proactor以及对应的句柄,在发起操作时,会创建ACE_WIN32_Asynch_Result,同时将处理器传入

win32异步结果实现类子类

ACE_Asynch_Result_Impl
ACE_WIN32_Asynch_Result
OVERLAPPED
ACE_Asynch_Read_Stream_Result_Impl
ACE_WIN32_Asynch_Read_Stream_Result
ACE_Asynch_Write_Stream_Result_Impl
ACE_WIN32_Asynch_Write_Stream_Result
ACE_Asynch_Read_File_Result_Impl
ACE_WIN32_Asynch_Read_File_Result
ACE_WIN32_Asynch_Write_File_Result
ACE_Asynch_Write_File_Result_Impl
ACE_Asynch_Accept_Result_Impl
ACE_WIN32_Asynch_Accept_Result
ACE_WIN32_Asynch_Connect_Result
ACE_Asynch_Connect_Result_Impl
ACE_Asynch_Transmit_File_Result_Impl
ACE_WIN32_Asynch_Transmit_File_Result
ACE_Asynch_Read_Dgram_Result_Impl
ACE_WIN32_Asynch_Read_Dgram_Result
ACE_Asynch_Write_Dgram_Result_Impl
ACE_WIN32_Asynch_Write_Dgram_Result

Posix异步操作实现类子类

ACE_POSIX_Asynch_Operation
ACE_Asynch_Operation_Impl
ACE_POSIX_Asynch_Read_Stream
ACE_Asynch_Read_Stream_Impl
ACE_POSIX_Asynch_Write_Stream
ACE_Asynch_Write_Stream_Impl
ACE_Asynch_Read_File_Impl
ACE_POSIX_Asynch_Read_File
ACE_Asynch_Write_File_Impl
ACE_POSIX_Asynch_Write_File
ACE_Asynch_Accept_Impl
ACE_POSIX_Asynch_Accept
ACE_Asynch_Connect_Impl
ACE_POSIX_Asynch_Connect
ACE_Asynch_Transmit_File_Impl
ACE_POSIX_Asynch_Transmit_File
ACE_Asynch_Read_Dgram_Impl
ACE_POSIX_Asynch_Read_Dgram

ACE_POSIX_Asynch_Operation :包含了处理器,所属的Proactor以及对应的句柄,在发起操作时,会创建ACE_POSIX_Asynch_Result,同时将处理器传入

Posix异步结果实现类子类

ACE_POSIX_Asynch_Result
ACE_Asynch_Result_Impl
aiocb
ACE_Asynch_Read_Stream_Result_Impl
ACE_POSIX_Asynch_Read_Stream_Result
ACE_Asynch_Write_Stream_Result_Impl
ACE_POSIX_Asynch_Write_Stream_Result
ACE_Asynch_Read_File_Result_Impl
ACE_POSIX_Asynch_Read_File_Result
ACE_Asynch_Write_File_Result_Impl
ACE_POSIX_Asynch_Write_File_Result
ACE_Asynch_Accept_Result_Impl
ACE_POSIX_Asynch_Accept_Result
ACE_Asynch_Connect_Result_Impl
ACE_POSIX_Asynch_Connect_Result
ACE_Asynch_Transmit_File_Result_Impl
ACE_POSIX_Asynch_Transmit_File_Result
ACE_Asynch_Write_Dgram_Result_Impl
ACE_POSIX_Asynch_Write_Dgram_Result
ACE_Asynch_Read_Dgram_Result_Impl
ACE_POSIX_Asynch_Read_Dgram_Result

时序

使用的是Handler,其调用时序为

client ACE_Handler ACE_Asynch_Operation子类 ACE_Asynch_Operation_Impl子类 ACE_Asynch_Operation_Result_Impl子类 ACE_Proactor_Impl子类 ACE_Async_Result_Impl子类 操作 operation operation New operation wrapper ACE_Async_Result子类 handleXX client ACE_Handler ACE_Asynch_Operation子类 ACE_Asynch_Operation_Impl子类 ACE_Asynch_Operation_Result_Impl子类 ACE_Proactor_Impl子类 ACE_Async_Result_Impl子类

Acceptor-Connector框架

ACE_Asynch_Acceptor<HANDLER>
# HANDLER *make_handler
ACE_Asynch_Connector<HANDLER>
#HANDLER *make_handler(void)
ACE_Handler
ACE_Service_Handler

Acceptor的时序为
以window平台的为例

user ACE_Asynch_Acceptor ACE_Asynch_Accept ACE_Proactor ACE_Asynch_Operation ACE_WIN32_Asynch_Accept ACE_WIN32_Asynch_Operation ACE_WIN32_Proactor ACE_OS ACE_Service_Handler open open create_asynch_accept implementation_ open open open register_handle bind listen accept handle_accept make_handler open user ACE_Asynch_Acceptor ACE_Asynch_Accept ACE_Proactor ACE_Asynch_Operation ACE_WIN32_Asynch_Accept ACE_WIN32_Asynch_Operation ACE_WIN32_Proactor ACE_OS ACE_Service_Handler

Connector的时序为
以window平台的为例

user ACE_Asynch_Connector ACE_Asynch_Connect ACE_Proactor ACE_WIN32_Asynch_Connect ACE_WIN32_Asynch_Operation ACE_Service_Handler open open create_asynch_connect open open register_handle 返回 connect connect handle_connect make_handler open user ACE_Asynch_Connector ACE_Asynch_Connect ACE_Proactor ACE_WIN32_Asynch_Connect ACE_WIN32_Asynch_Operation ACE_Service_Handler
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

kgduu

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

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

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

打赏作者

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

抵扣说明:

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

余额充值