3 //=============================================================================
5 * @file Priority_Reactor.h
7 * $Id: Priority_Reactor.h 80826 2008-03-04 14:51:23Z wotte $
9 * @author Carlos O'Ryan <coryan@uci.edu>
11 //=============================================================================
13 #ifndef ACE_PRIORITY_REACTOR_H
14 #define ACE_PRIORITY_REACTOR_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "ace/ACE_export.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include "ace/Select_Reactor.h"
24 #include "ace/Unbounded_Queue.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
29 * @class ACE_Priority_Reactor
31 * @brief Implements priority based dispatching.
33 * This class refines the dispatching mechanism for the
34 * Select_Reactor by taking advantage of the priority method on
37 class ACE_Export ACE_Priority_Reactor
: public ACE_Select_Reactor
40 // = Initialization and termination methods.
42 /// Initialize ACE_Priority_Reactor with the default size.
43 ACE_Priority_Reactor (ACE_Sig_Handler
* = 0,
44 ACE_Timer_Queue
* = 0);
46 /// Initialize ACE_Priority_Reactor with size @a size.
47 ACE_Priority_Reactor (size_t size
,
49 ACE_Sig_Handler
* = 0,
50 ACE_Timer_Queue
* = 0);
52 /// Close down the select_reactor and release all of its resources.
53 virtual ~ACE_Priority_Reactor (void);
55 /// Dump the state of an object.
56 void dump (void) const;
58 /// Declare the dynamic allocation hooks.
59 ACE_ALLOC_HOOK_DECLARE
;
62 // = Dispatching methods.
64 /// We simply override this function to implement the priority
66 virtual int dispatch_io_set (int number_of_active_handles
,
67 int &number_dispatched
,
69 ACE_Handle_Set
&dispatch_mask
,
70 ACE_Handle_Set
&ready_mask
,
71 ACE_EH_PTMF callback
);
74 /// A small helper to initialize the bucket.
75 void init_bucket (void);
77 /// Build the bucket from the given dispatch_mask. Return -1 on
78 /// failure, 0 otherwise.
79 int build_bucket (ACE_Handle_Set
& dispatch_mask
,
83 /// There is a queue per-priority, which simply holds the
84 /// Event_Handlers until we know who goes first.
85 typedef ACE_Unbounded_Queue
<ACE_Event_Tuple
> QUEUE
;
88 /// The queues themselves use this allocator to minimize dynamic
90 ACE_Allocator
* tuple_allocator_
;
92 /// Deny access since member-wise won't work...
93 ACE_Priority_Reactor (const ACE_Priority_Reactor
&);
94 ACE_Priority_Reactor
&operator = (const ACE_Priority_Reactor
&);
97 ACE_END_VERSIONED_NAMESPACE_DECL
99 #include /**/ "ace/post.h"
100 #endif /* ACE_PRIORITY_REACTOR_H */