ACE_Event_Handler
/**
* @class ACE_Event_Handler
*
* @brief Provides an abstract interface for handling various types of
* I/O, timer, and signal events.
*
* Subclasses read/write input/output on an I/O descriptor,
* handle an exception raised on an I/O descriptor, handle a
* timer's expiration, or handle a signal.
*/
ACE_Event_Handler 眉头注释: 提供一个抽象接口,处理各种 I/O, 定时器和信号(事件)
子类处理下面事情: 读写一个 I/O 描述字; 处理 I/O 描述字产生的异常; 处理定时器触发事件; 处理一个信号.
/// Destructor is virtual to enable proper cleanup.
virtual ~ACE_Event_Handler (void);
析构函数声明成虚的, 使得多态时保证调用子类的析构函数,让对象得到合适的析构。
/// Get the I/O handle.
virtual ACE_HANDLE get_handle (void) const;
得到 I/O handle
/// Set the I/O handle.
virtual void set_handle (ACE_HANDLE);
设置 I/O handle
// Priorities run from MIN_PRIORITY (which is the "lowest priority")
// to MAX_PRIORITY (which is the "highest priority").
/// Get the priority of the Event_Handler.
virtual int priority (void) const;
/// Set the priority of the Event_Handler.
virtual void priority (int priority);
优先级取值区间 [MIN_PRIORITY, MAX_PRIORITY]; 这里是优先级的 获取和设置方法。
/// Called when input events occur (e.g., connection or data).
virtual int handle_input (ACE_HANDLE fd = ACE_INVALID_HANDLE);
当有输入事件产生时, handle_input 会被调用。“输入事件”包含 一个新的连接,一些数据到达 I/O 等。
/// Called when output events are possible (e.g., when flow control
/// abates or non-blocking connection completes).
virtual int handle_output (ACE_HANDLE fd = ACE_INVALID_HANDLE);
当输出事件可行时,handle_out 函数会被调用。输出事件包含 流控制缓和(应该是指底层发送缓存不再是满的状态), 非阻塞连接完成了。
/// Called when an exceptional events occur (e.g., SIGURG).
virtual int handle_exception (ACE_HANDLE fd = ACE_INVALID_HANDLE);
当一个异常的事件发生时, SIGURG 信号会被触发。 异常的时间包含 “SIGURG 信号到达” 等。 当 Out_Of_Band data(带外数据) 到达了 socket, SIGURG 信号会被发送给 socket 的宿主进程。
/**
* Called when timer expires. @a current_time represents the current
* time that the Event_Handler was selected for timeout
* dispatching and @a act is the asynchronous completion token that
* was passed in when <schedule_timer> was invoked.
*/
virtual int handle_timeout (const ACE_Time_Value ¤t_time,
const void *act = 0);
当定时器触发时 handle_timeout 函数会被调用; 第一个参数 current _time 表示 当前时间,这个时间是 Event_Handler 被选择超时分发的时间点。 第二个参数是异步完成标志, 这个标志是通过 schedule_timer 设置定时器时指定的。
/// Called when a process exits.
virtual int handle_exit (ACE_Process *);
当进程退出时, handle_exit 函数会被调用。
/// Called when a <handle_*()> method returns -1 or when the
/// <remove_handler> method is called on an ACE_Reactor. The
/// @a close_mask indicates which event has triggered the
/// <handle_close> method callback on a particular @a handle.
virtual int handle_close (ACE_HANDLE handle,
ACE_Reactor_Mask close_mask);
当某一个 handle_*() 方法返回 -1 时 或者 remove_handler 对一个 ACE_Reactor 调用时, handle_close 函数会被调用。第二个参数 close_mask 指明是哪个事件触发调用了 hand_close 回调方法, 第一个是发生事件的 handle.
/// Called when object is signaled by OS (either via UNIX signals or
/// when a Win32 object becomes signaled).
virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0);
当对象收到操作系统的信号时,handle_signal 函数会被调用。
/**
* Called to figure out whether the handler needs to resumed by the
* reactor or the application can take care of it. The default
* value of 0 would be returned which would allow the reactor to
* take care of resumption of the handler. The application can
* return a value more than zero and decide to resume the handler
* themseleves.
*
* @note This method is only useful for the ACE_TP_Reactor. Sad
* that we have to have this method in a class that is supposed to
* be used across different components in ACE.
*/
virtual int resume_handler (void);
这个函数会被调用来找出,到底是 reactor 需要接手 handler 还是上层应用程序接手 handler. 如果底层的函数没有重新实现此函数, 那么默认值 0 将被返回。 0 表示reactor 被允许接手 handler. 上层程序可以重载这个虚函数的实现,返回大于 0 的数字,表示上层程序将接受 handler.
// = Accessors to set/get the various event demultiplexors.
/// Set the event demultiplexors.
virtual void reactor (ACE_Reactor *reactor);
/// Get the event demultiplexors.
virtual ACE_Reactor *reactor (void) const;
/// Get only the reactor's timer related interface.
virtual ACE_Reactor_Timer_Interface *reactor_timer_interface (void) const;
取得和设置多路复用解调器。
取得多路复用解调器的时间相关接口
<其他的很多看不懂>
未完。。。