Priority_Reactor.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Priority_Reactor.h
00006  *
00007  *  Priority_Reactor.h,v 4.22 2005/11/26 03:13:13 ossama Exp
00008  *
00009  *  @author Carlos O'Ryan <coryan@uci.edu>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_PRIORITY_REACTOR_H
00014 #define ACE_PRIORITY_REACTOR_H
00015 #include /**/ "ace/pre.h"
00016 
00017 #include "ace/ACE_export.h"
00018 
00019 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00020 # pragma once
00021 #endif /* ACE_LACKS_PRAGMA_ONCE */
00022 
00023 #include "ace/Select_Reactor.h"
00024 #include "ace/Unbounded_Queue.h"
00025 
00026 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00027 
00028 /**
00029  * @class ACE_Priority_Reactor
00030  *
00031  * @brief Implements priority based dispatching.
00032  *
00033  * This class refines the dispatching mechanism for the
00034  * Select_Reactor by taking advantage of the priority method on
00035  * ACE_Event_Handler.
00036  */
00037 class ACE_Export ACE_Priority_Reactor : public ACE_Select_Reactor
00038 {
00039 public:
00040   // = Initialization and termination methods.
00041 
00042   /// Initialize <ACE_Priority_Reactor> with the default size.
00043   ACE_Priority_Reactor (ACE_Sig_Handler * = 0,
00044                         ACE_Timer_Queue * = 0);
00045 
00046   /// Initialize <ACE_Priority_Reactor> with size <size>.
00047   ACE_Priority_Reactor (size_t size,
00048                         int restart = 0,
00049                         ACE_Sig_Handler * = 0,
00050                         ACE_Timer_Queue * = 0);
00051 
00052   /// Close down the select_reactor and release all of its resources.
00053   virtual ~ACE_Priority_Reactor (void);
00054 
00055   /// Dump the state of an object.
00056   void dump (void) const;
00057 
00058   /// Declare the dynamic allocation hooks.
00059   ACE_ALLOC_HOOK_DECLARE;
00060 
00061 protected:
00062   // = Dispatching methods.
00063 
00064   /// We simply override this function to implement the priority
00065   /// dispatching.
00066   virtual int dispatch_io_set (int number_of_active_handles,
00067                                int &number_dispatched,
00068                                int mask,
00069                                ACE_Handle_Set &dispatch_mask,
00070                                ACE_Handle_Set &ready_mask,
00071                                ACE_EH_PTMF callback);
00072 
00073 private:
00074   /// A small helper to initialize the bucket.
00075   void init_bucket (void);
00076 
00077   /// Build the bucket from the given dispatch_mask
00078   void build_bucket (ACE_Handle_Set& dispatch_mask,
00079                      int &min_priority,
00080                      int &max_priority);
00081 
00082   /// There is a queue per-priority, which simply holds the
00083   /// Event_Handlers until we know who goes first.
00084   typedef ACE_Unbounded_Queue<ACE_Event_Tuple> QUEUE;
00085   QUEUE** bucket_;
00086 
00087   /// The queues themselves use this allocator to minimize dynamic
00088   /// memory usage.
00089   ACE_Allocator* tuple_allocator_;
00090 
00091   /// Deny access since member-wise won't work...
00092   ACE_Priority_Reactor (const ACE_Priority_Reactor &);
00093   ACE_Priority_Reactor &operator = (const ACE_Priority_Reactor &);
00094 };
00095 
00096 ACE_END_VERSIONED_NAMESPACE_DECL
00097 
00098 #include /**/ "ace/post.h"
00099 #endif /* ACE_PRIORITY_REACTOR_H */

Generated on Thu Nov 9 09:41:59 2006 for ACE by doxygen 1.3.6