|
楼主 |
发表于 2007-12-13 23:41:04
|
显示全部楼层
恩 找到了
顺便贴出来
The ACE_Reactor's registration and removal methods offer multiple overloaded signatures to
facilitate their use in many different situations. For example, the register_handler()
methods can be used with any of the following signatures:
(ACE_Event_Handler *, ACE_Reactor_Mask)? In this version, the first parameter identifies
the application's event handler and the second indicates the type of event(s) the handler
is prepared to process. The method's implementation uses double-dispatching [GoF] to
obtain a handle via the handler's get_handle() method. The advantage of this design is
that application code need not obtain nor expose an I/O handle explicitly, which prevents
accidental association of the wrong handle with an event handler. Most examples in this
book therefore use this variant of register_handler().
(ACE_HANDLE, ACE_Event_Handler *, ACE_Reactor_Mask)? In this version, a new first
parameter is added to explicitly specify the I/O handle associated with the application's
event handler. This design is potentially more error-prone than the two-parameter version
above since callers can accidentally pass an I/O handle that doesn't match the event
handler. However, it allows an application to register multiple I/O handles for the same
event handler, which is necessary for handlers that must be associated with multiple IPC
objects. This method can also be used to conserve memory if a single event handler can
process events from many unrelated I/O streams that don't require maintenance of per-
handle state. The client logging daemon example in the Example portion of Section 6.2
illustrates the three parameter variant of register_handler(). |
|