3 //=============================================================================
5 * @file Priority_Reactor.h
7 * @author Carlos O'Ryan <coryan@uci.edu>
9 //=============================================================================
11 #ifndef ACE_PRIORITY_REACTOR_H
12 #define ACE_PRIORITY_REACTOR_H
13 #include /**/ "ace/pre.h"
15 #include /**/ "ace/ACE_export.h"
17 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 #endif /* ACE_LACKS_PRAGMA_ONCE */
21 #include "ace/Select_Reactor.h"
22 #include "ace/Unbounded_Queue.h"
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 * @class ACE_Priority_Reactor
29 * @brief Implements priority based dispatching.
31 * This class refines the dispatching mechanism for the
32 * Select_Reactor by taking advantage of the priority method on
35 class ACE_Export ACE_Priority_Reactor
: public ACE_Select_Reactor
38 /// Initialize ACE_Priority_Reactor with the default size.
39 ACE_Priority_Reactor (ACE_Sig_Handler
* = 0,
40 ACE_Timer_Queue
* = 0);
42 /// Initialize ACE_Priority_Reactor with size @a size.
43 ACE_Priority_Reactor (size_t size
,
45 ACE_Sig_Handler
* = 0,
46 ACE_Timer_Queue
* = 0);
48 /// Close down the select_reactor and release all of its resources.
49 virtual ~ACE_Priority_Reactor ();
51 /// Dump the state of an object.
54 /// Declare the dynamic allocation hooks.
55 ACE_ALLOC_HOOK_DECLARE
;
58 // = Dispatching methods.
60 /// We simply override this function to implement the priority
62 virtual int dispatch_io_set (int number_of_active_handles
,
63 int &number_dispatched
,
65 ACE_Handle_Set
&dispatch_mask
,
66 ACE_Handle_Set
&ready_mask
,
67 ACE_EH_PTMF callback
);
70 /// A small helper to initialize the bucket.
73 /// Build the bucket from the given dispatch_mask. Return -1 on
74 /// failure, 0 otherwise.
75 int build_bucket (ACE_Handle_Set
& dispatch_mask
,
79 /// There is a queue per-priority, which simply holds the
80 /// Event_Handlers until we know who goes first.
81 typedef ACE_Unbounded_Queue
<ACE_Event_Tuple
> QUEUE
;
84 /// The queues themselves use this allocator to minimize dynamic
86 ACE_Allocator
* tuple_allocator_
;
88 /// Deny access since member-wise won't work...
89 ACE_Priority_Reactor (const ACE_Priority_Reactor
&);
90 ACE_Priority_Reactor
&operator = (const ACE_Priority_Reactor
&);
93 ACE_END_VERSIONED_NAMESPACE_DECL
95 #include /**/ "ace/post.h"
96 #endif /* ACE_PRIORITY_REACTOR_H */