Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members File Members Related Pages

# ACE_TP_Reactor Class Reference

Specialization of Select Reactor to support thread-pool based event dispatching. More...

`#include <TP_Reactor.h>`

Inheritance diagram for ACE_TP_Reactor:

[legend]
Collaboration diagram for ACE_TP_Reactor:

[legend]
List of all members.

## Public Methods
| ACE_TP_Reactor (ACE_Sig_Handler *=0, ACE_Timer_Queue *=0, int mask_signals=1, int s_queue=ACE_Select_Reactor_Token::FIFO)
| Initialize <ACE_TP_Reactor> with the default size. More...
| ACE_TP_Reactor (size_t max_number_of_handles, int restart=0, ACE_Sig_Handler *=0, ACE_Timer_Queue *=0, int mask_signals=1, int s_queue=ACE_Select_Reactor_Token::FIFO)
| Initialize the <ACE_TP_Reactor> to manage <max_number_of_handles>. More...
virtual int | handle_events (ACE_Time_Value *max_wait_time=0)
| This event loop driver that blocks for <max_wait_time> before returning. More...
virtual int | handle_events (ACE_Time_Value &max_wait_time)
| This method is just like the one above, except the <max_wait_time> value is a reference and can therefore never be NULL. More...
virtual int | remove_handler (ACE_Event_Handler *eh, ACE_Reactor_Mask mask)
| Removes the <mask> binding of <eh> from the Select_Reactor. More...
virtual int | remove_handler (ACE_HANDLE handle, ACE_Reactor_Mask)
| Removes the <mask> bind of <Event_Handler> whose handle is <handle> from the Select_Reactor. More...
virtual int | remove_handler (const ACE_Handle_Set &handle_set, ACE_Reactor_Mask)
| Removes all the <mask> bindings for handles in the <handle_set> bind of <Event_Handler>. More...
virtual int | remove_handler (int signum, ACE_Sig_Action *new_disp, ACE_Sig_Action *old_disp=0, int sigkey=-1)
| Remove the ACE_Event_Handler currently associated with <signum>. More...
virtual int | remove_handler (const ACE_Sig_Set &sigset)
| Calls <remove_handler> for every signal in <sigset>. More...
virtual int | resumable_handler (void)
| Does the reactor allow the application to resume the handle on its own ie. can it pass on the control of handle resumption to the application. The TP reactor has can allow applications to resume handles. So return a +ve value. More...
virtual int | mask_ops (ACE_Event_Handler *eh, ACE_Reactor_Mask mask, int ops)
| GET/SET/ADD/CLR the dispatch mask "bit" bound with the <eh> and <mask>. More...
virtual int | mask_ops (ACE_HANDLE handle, ACE_Reactor_Mask mask, int ops)
| GET/SET/ADD/CLR the dispatch mask "bit" bound with the <handle> and <mask>. More...
virtual int | owner (ACE_thread_t n_id, ACE_thread_t *o_id=0)
| Set the new owner of the thread and return the old owner. More...
virtual int | owner (ACE_thread_t *)
| Return the current owner of the thread. More...
## Static Public Methods
void | no_op_sleep_hook (void *)
| Called from handle events. More...
## Public Attributes
| ACE_ALLOC_HOOK_DECLARE
| Declare the dynamic allocation hooks. More...
## Protected Methods
int | dispatch_i (ACE_Time_Value *max_wait_time, ACE_TP_Token_Guard &guard)
| Dispatch just 1 signal, timer, notification handlers. More...
int | get_event_for_dispatching (ACE_Time_Value *max_wait_time)
| Get the event that needs dispatching.It could be either a signal, timer, notification handlers or return possibly 1 I/O handler for dispatching. In the most common use case, this would return 1 I/O handler for dispatching. More...
int | handle_signals (int &event_count, ACE_TP_Token_Guard &g)
| Method to handle signals NOTE: It is just busted at this point in time. More...
int | handle_timer_events (int &event_count, ACE_TP_Token_Guard &g)
| Handle timer events. More...
int | handle_notify_events (int &event_count, ACE_TP_Token_Guard &g)
| Handle notify events. More...
int | handle_socket_events (int &event_count, ACE_TP_Token_Guard &g)
| handle socket events. More...
virtual void | notify_handle (ACE_HANDLE handle, ACE_Reactor_Mask mask, ACE_Handle_Set &, ACE_Event_Handler *eh, ACE_EH_PTMF callback)
| This method shouldn't get called. More...
## Private Methods
ACE_HANDLE | get_notify_handle (void)
| Get the handle of the notify pipe from the ready set if there is an event in the notify pipe. More...
int | get_socket_event_info (ACE_EH_Dispatch_Info &info)
| Get socket event dispatch information. More...
int | dispatch_socket_event (ACE_EH_Dispatch_Info &dispatch_info)
| Notify the appropriate <callback> in the context of the <eh> associated with <handle> that a particular event has occurred. More...
| ACE_TP_Reactor (const ACE_TP_Reactor &)
| Deny access since member-wise won't work... More...
ACE_TP_Reactor & | operator= (const ACE_TP_Reactor &)

## Detailed Description

Specialization of Select Reactor to support thread-pool based event dispatching.

One of the short comings of the Select_Reactor in ACE is that it did not support a thread pool based event dispatching model, similar to the one in WFMO_Reactor. In Select_Reactor, only thread can be blocked in <handle_events> at any given time. A new Reactor has been added to ACE that removes this short-coming. TP_Reactor is a specialization of Select Reactor to support thread-pool based event dispatching. This Reactor takes advantage of the fact that events reported by <select> are persistent if not acted upon immediately. It works by remembering the event handler that just got activated, releasing the internal lock (so that some other thread can start waiting in the event loop) and then dispatching the event handler outside the context of the Reactor lock. This Reactor is best suited for situations when the callbacks to event handlers can take arbitrarily long and/or a number of threads are available to run the event loops. Note that callback code in Event Handlers (e.g. Event_Handler::handle_input) does not have to be modified or made thread-safe for this Reactor. This is because an activated Event Handler is suspended in the Reactor before the upcall is made and resumed after the upcall completes. Therefore, one Event Handler cannot be called by multiple threads simultaneously.

## Constructor & Destructor Documentation

ACE_TP_Reactor::ACE_TP_Reactor | ( | ACE_Sig_Handler * | sh = 0,
|  | ACE_Timer_Queue * | tq = 0,
|  | int | mask_signals = 1,
|  | int | s_queue = ACE_Select_Reactor_Token::FIFO
| ) |

| Initialize <ACE_TP_Reactor> with the default size.

ACE_TP_Reactor::ACE_TP_Reactor | ( | size_t | size,
|  | int | rs = 0,
|  | ACE_Sig_Handler * | sh = 0,
|  | ACE_Timer_Queue * | tq = 0,
|  | int | mask_signals = 1,
|  | int | s_queue = ACE_Select_Reactor_Token::FIFO
| ) |

| Initialize the <ACE_TP_Reactor> to manage <max_number_of_handles>. If <restart> is non-0 then the <ACE_Reactor>'s <handle_events> method will be restarted automatically when <EINTR> occurs. If <signal_handler> or <timer_queue> are non-0 they are used as the signal handler and timer queue, respectively.

ACE_TP_Reactor::ACE_TP_Reactor | ( | const ACE_TP_Reactor & |  | ) | `[private]`

| Deny access since member-wise won't work...

## Member Function Documentation

int ACE_TP_Reactor::dispatch_i | ( | ACE_Time_Value * | max_wait_time,
|  | ACE_TP_Token_Guard & | guard
| ) | `[protected]`

| Dispatch just 1 signal, timer, notification handlers.

int ACE_TP_Reactor::dispatch_socket_event | ( | ACE_EH_Dispatch_Info & | dispatch_info | ) | `[private]`

| Notify the appropriate <callback> in the context of the <eh> associated with <handle> that a particular event has occurred.

int ACE_TP_Reactor::get_event_for_dispatching | ( | ACE_Time_Value * | max_wait_time | ) | `[protected]`

| Get the event that needs dispatching.It could be either a signal, timer, notification handlers or return possibly 1 I/O handler for dispatching. In the most common use case, this would return 1 I/O handler for dispatching.

ACE_HANDLE ACE_TP_Reactor::get_notify_handle | ( | void |  | ) | `[private]`

| Get the handle of the notify pipe from the ready set if there is an event in the notify pipe.

int ACE_TP_Reactor::get_socket_event_info | ( | ACE_EH_Dispatch_Info & | event | ) | `[private]`

| Get socket event dispatch information.

int ACE_TP_Reactor::handle_events | ( | ACE_Time_Value & | max_wait_time | ) | `[virtual]`

| This method is just like the one above, except the <max_wait_time> value is a reference and can therefore never be NULL. The only difference between <alertable_handle_events> and <handle_events> is that in the alertable case, the eventloop will return when the system queues an I/O completion routine or an Asynchronous Procedure Call. Reimplemented from ACE_Reactor_Impl.

int ACE_TP_Reactor::handle_events | ( | ACE_Time_Value * | max_wait_time = 0 | ) | `[virtual]`

| This event loop driver that blocks for <max_wait_time> before returning. It will return earlier if timer events, I/O events, or signal events occur. Note that <max_wait_time> can be 0, in which case this method blocks indefinitely until events occur. <max_wait_time> is decremented to reflect how much time this call took. For instance, if a time value of 3 seconds is passed to handle_events and an event occurs after 2 seconds, <max_wait_time> will equal 1 second. This can be used if an application wishes to handle events for some fixed amount of time. Returns the total number of <ACE_Event_Handler>s that were dispatched, 0 if the <max_wait_time> elapsed without dispatching any handlers, or -1 if something goes wrong. Reimplemented from ACE_Reactor_Impl.

int ACE_TP_Reactor::handle_notify_events | ( | int & | event_count,
|  | ACE_TP_Token_Guard & | guard
| ) | `[protected]`

| Handle notify events.

int ACE_TP_Reactor::handle_signals | ( | int & | event_count,
|  | ACE_TP_Token_Guard & | g
| ) | `[protected]`

| Method to handle signals NOTE: It is just busted at this point in time.

int ACE_TP_Reactor::handle_socket_events | ( | int & | event_count,
|  | ACE_TP_Token_Guard & | guard
| ) | `[protected]`

| handle socket events.

int ACE_TP_Reactor::handle_timer_events | ( | int & | event_count,
|  | ACE_TP_Token_Guard & | guard
| ) | `[protected]`

| Handle timer events.

int ACE_TP_Reactor::mask_ops | ( | ACE_HANDLE | handle,
|  | ACE_Reactor_Mask | mask,
|  | int | ops
| ) | `[virtual]`

| GET/SET/ADD/CLR the dispatch mask "bit" bound with the <handle> and <mask>. Reimplemented from ACE_Reactor_Impl.

int ACE_TP_Reactor::mask_ops | ( | ACE_Event_Handler * | eh,
|  | ACE_Reactor_Mask | mask,
|  | int | ops
| ) | `[virtual]`

| GET/SET/ADD/CLR the dispatch mask "bit" bound with the <eh> and <mask>. Reimplemented from ACE_Reactor_Impl.

ACE_INLINE void ACE_TP_Reactor::no_op_sleep_hook | ( | void * |  | ) | `[static]`

| Called from handle events.

void ACE_TP_Reactor::notify_handle | ( | ACE_HANDLE | handle,
|  | ACE_Reactor_Mask | mask,
|  | ACE_Handle_Set & | ready_mask,
|  | ACE_Event_Handler * | eh,
|  | ACE_EH_PTMF | callback
| ) | `[protected, virtual]`

| This method shouldn't get called. Reimplemented from ACE_Select_Reactor_T.

ACE_TP_Reactor& ACE_TP_Reactor::operator= | ( | const ACE_TP_Reactor & |  | ) | `[private]`

int ACE_TP_Reactor::owner | ( | ACE_thread_t * | t_id | ) | `[virtual]`

| Return the current owner of the thread. Reimplemented from ACE_Reactor_Impl.

int ACE_TP_Reactor::owner | ( | ACE_thread_t | n_id,
|  | ACE_thread_t * | o_id = 0
| ) | `[virtual]`

| Set the new owner of the thread and return the old owner. Reimplemented from ACE_Reactor_Impl.

int ACE_TP_Reactor::remove_handler | ( | const ACE_Sig_Set & | sigset | ) | `[virtual]`

| Calls <remove_handler> for every signal in <sigset>. Reimplemented from ACE_Reactor_Impl.

int ACE_TP_Reactor::remove_handler | ( | int | signum,
|  | ACE_Sig_Action * | new_disp,
|  | ACE_Sig_Action * | old_disp = 0,
|  | int | sigkey = -1
| ) | `[virtual]`

| Remove the ACE_Event_Handler currently associated with <signum>. <sigkey> is ignored in this implementation since there is only one instance of a signal handler. Install the new disposition (if given) and return the previous disposition (if desired by the caller). Returns 0 on success and -1 if <signum> is invalid. Reimplemented from ACE_Reactor_Impl.

int ACE_TP_Reactor::remove_handler | ( | const ACE_Handle_Set & | handles,
|  | ACE_Reactor_Mask | m
| ) | `[virtual]`

| Removes all the <mask> bindings for handles in the <handle_set> bind of <Event_Handler>. If there are no more bindings for any of these handlers then they are removed from the Select_Reactor. Reimplemented from ACE_Reactor_Impl.

int ACE_TP_Reactor::remove_handler | ( | ACE_HANDLE | handle,
|  | ACE_Reactor_Mask | mask
| ) | `[virtual]`

| Removes the <mask> bind of <Event_Handler> whose handle is <handle> from the Select_Reactor. If there are no more bindings for this <eh> then it is removed from the Select_Reactor. Reimplemented from ACE_Reactor_Impl.

int ACE_TP_Reactor::remove_handler | ( | ACE_Event_Handler * | eh,
|  | ACE_Reactor_Mask | mask
| ) | `[virtual]`

| Removes the <mask> binding of <eh> from the Select_Reactor. If there are no more bindings for this <eh> then it is removed from the Select_Reactor. Note that the Select_Reactor will call <ACE_Event_Handler::get_handle> to extract the underlying I/O handle. Reimplemented from ACE_Reactor_Impl.

int ACE_TP_Reactor::resumable_handler | ( | void |  | ) | `[virtual]`

| Does the reactor allow the application to resume the handle on its own ie. can it pass on the control of handle resumption to the application. The TP reactor has can allow applications to resume handles. So return a +ve value. Reimplemented from ACE_Select_Reactor_Impl.

## Member Data Documentation

ACE_TP_Reactor::ACE_ALLOC_HOOK_DECLARE

| Declare the dynamic allocation hooks. Reimplemented from ACE_Reactor_Impl.

The documentation for this class was generated from the following files:

- TP_Reactor.h
- TP_Reactor.cpp
- TP_Reactor.i