/* -*- C++ -*- */ // $Id$ // ============================================================================ // // = LIBRARY // ace // // = FILENAME // TP_Reactor.h // // = DESCRIPTION // TP_Reactor (ala, Thread Pool Reactor) uses the leader-follower // model to demultiplex requests among a bunch of threads. // Basically, when using thread pool reactor, one will pre-spawn a // _fixed_ number of threads. When you issue the // method, one of the thread will become the leader thread and wait // for an event. The other threads (followers) will be lined up // and waiting for their turns 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 TP_Reactor // 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 only so // many threads.) // // = AUTHOR // Irfan Pyarali // Nanbor Wang // // ============================================================================ #ifndef ACE_TP_REACTOR_H #define ACE_TP_REACTOR_H #include "ace/Select_Reactor.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ class ACE_Export ACE_EH_Dispatch_Info { // = TITLE // // This structure contains information of the activated event // handler. 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_; }; class ACE_Export ACE_TP_Reactor : public ACE_Select_Reactor { // = TITLE // // Specialization of Select Reactor to support thread-pool based // event dispatching. // // = DESCRIPTION // // 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 //