/* -*- C++ -*- */ //============================================================================= /** * @file TP_Reactor.h * * $Id$ * * The (aka, Thread Pool Reactor) uses the * Leader/Followers pattern to demultiplex events among a pool of * threads. When using a thread pool reactor, an application * pre-spawns a _fixed_ number of threads. When these threads * invoke the 's method, one thread * will become the leader and wait for an event. The other * follower threads will queue up waiting for their turn to become * the leader. When an event occurs, the leader will pick a * follower to become the leader and go on to handle the event. * The consequence of using is the amortization of * the costs used to creating threads. The context switching cost * will also reduce. More over, the total resources used by * threads are bounded because there are a fixed number of threads. * * * @author Irfan Pyarali * @author Nanbor Wang */ //============================================================================= #ifndef ACE_TP_REACTOR_H #define ACE_TP_REACTOR_H #include "ace/pre.h" #include "ace/Select_Reactor.h" #include "ace/Log_Msg.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ /** * @class ACE_EH_Dispatch_Info * * @brief This structure contains information of the activated event * handler. */ class ACE_Export ACE_EH_Dispatch_Info { public: ACE_EH_Dispatch_Info (void); void set (ACE_HANDLE handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask, ACE_EH_PTMF callback); void reset (void); int dispatch (void) const; ACE_HANDLE handle_; ACE_Event_Handler *event_handler_; ACE_Reactor_Mask mask_; ACE_EH_PTMF callback_; int dispatch_; private: ACE_UNIMPLEMENTED_FUNC (ACE_EH_Dispatch_Info (const ACE_EH_Dispatch_Info &)) ACE_UNIMPLEMENTED_FUNC (ACE_EH_Dispatch_Info &operator= (const ACE_EH_Dispatch_Info &)) }; /** * @class ACE_TP_Reactor * * @brief 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 * 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 *