ACE  6.2.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY > Class Template Reference

A derived class which adapts the ACE_Message_Queue class in order to maintain dynamic priorities for enqueued <ACE_Message_Blocks> and manage the queue order according to these dynamic priorities. More...

#include <Message_Queue_T.h>

Inheritance diagram for ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >:
Collaboration graph
[legend]

Public Member Functions

 ACE_Dynamic_Message_Queue (ACE_Dynamic_Message_Strategy &message_strategy, size_t hwm=ACE_Message_Queue_Base::DEFAULT_HWM, size_t lwm=ACE_Message_Queue_Base::DEFAULT_LWM, ACE_Notification_Strategy *=0)
 
virtual ~ACE_Dynamic_Message_Queue (void)
 Close down the message queue and release all resources. More...
 
virtual int remove_messages (ACE_Message_Block *&list_head, ACE_Message_Block *&list_tail, u_int status_flags)
 
virtual int dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout=0)
 
virtual void dump (void) const
 Dump the state of the queue. More...
 
virtual int enqueue_tail (ACE_Message_Block *new_item, ACE_Time_Value *timeout=0)
 
virtual int enqueue_head (ACE_Message_Block *new_item, ACE_Time_Value *timeout=0)
 
- Public Member Functions inherited from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >
virtual int close (void)
 
virtual ~ACE_Message_Queue (void)
 Releases all resources from the message queue and marks it deactivated. More...
 
virtual int flush (void)
 
virtual int flush_i (void)
 
virtual ACE_SYNCH_MUTEX_Tlock (void)
 Returns a reference to the lock used by the ACE_Message_Queue. More...
 
ACE_Time_Value_T< TIME_POLICY > gettimeofday (void) const
 
void set_time_policy (TIME_POLICY const &time_policy)
 
 ACE_Message_Queue (size_t hwm=ACE_Message_Queue_Base::DEFAULT_HWM, size_t lwm=ACE_Message_Queue_Base::DEFAULT_LWM, ACE_Notification_Strategy *ns=0)
 
virtual int open (size_t hwm=ACE_Message_Queue_Base::DEFAULT_HWM, size_t lwm=ACE_Message_Queue_Base::DEFAULT_LWM, ACE_Notification_Strategy *ns=0)
 
virtual int enqueue_prio (ACE_Message_Block *new_item, ACE_Time_Value *timeout=0)
 
virtual int enqueue_deadline (ACE_Message_Block *new_item, ACE_Time_Value *timeout=0)
 
virtual int enqueue (ACE_Message_Block *new_item, ACE_Time_Value *timeout=0)
 
virtual int dequeue (ACE_Message_Block *&first_item, ACE_Time_Value *timeout=0)
 This method is an alias for the dequeue_head() method. More...
 
virtual int dequeue_prio (ACE_Message_Block *&first_item, ACE_Time_Value *timeout=0)
 
virtual int dequeue_tail (ACE_Message_Block *&dequeued, ACE_Time_Value *timeout=0)
 
virtual int dequeue_deadline (ACE_Message_Block *&dequeued, ACE_Time_Value *timeout=0)
 
virtual bool is_full (void)
 True if queue is full, else false. More...
 
virtual bool is_empty (void)
 True if queue is empty, else false. More...
 
virtual size_t message_bytes (void)
 
virtual void message_bytes (size_t new_size)
 
virtual size_t message_length (void)
 
virtual void message_length (size_t new_length)
 
virtual size_t message_count (void)
 
virtual size_t high_water_mark (void)
 
virtual void high_water_mark (size_t hwm)
 
virtual size_t low_water_mark (void)
 
virtual void low_water_mark (size_t lwm)
 
virtual int deactivate (void)
 
virtual int activate (void)
 
virtual int pulse (void)
 
virtual int state (void)
 
virtual int deactivated (void)
 
virtual int notify (void)
 
virtual ACE_Notification_Strategynotification_strategy (void)
 Get the notification strategy for the <Message_Queue> More...
 
virtual void notification_strategy (ACE_Notification_Strategy *s)
 Set the notification strategy for the <Message_Queue> More...
 
- Public Member Functions inherited from ACE_Message_Queue_Base
 ACE_Message_Queue_Base (void)
 
virtual ~ACE_Message_Queue_Base (void)
 Close down the message queue and release all resources. More...
 

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...
 
- Public Attributes inherited from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >
 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...
 
- Public Attributes inherited from ACE_Message_Queue_Base
 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...
 

Protected Member Functions

virtual int enqueue_i (ACE_Message_Block *new_item)
 
virtual int sublist_enqueue_i (ACE_Message_Block *new_item, const ACE_Time_Value &current_time, ACE_Message_Block *&sublist_head, ACE_Message_Block *&sublist_tail, ACE_Dynamic_Message_Strategy::Priority_Status status)
 Enqueue a message in priority order within a given priority status sublist. More...
 
virtual int dequeue_head_i (ACE_Message_Block *&first_item)
 
virtual int refresh_queue (const ACE_Time_Value &current_time)
 
virtual int refresh_pending_queue (const ACE_Time_Value &current_time)
 
virtual int refresh_late_queue (const ACE_Time_Value &current_time)
 
- Protected Member Functions inherited from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >
virtual int enqueue_deadline_i (ACE_Message_Block *new_item)
 Enqueue an <ACE_Message_Block *> in accordance with its deadline time. More...
 
virtual int enqueue_tail_i (ACE_Message_Block *new_item)
 Enqueue an <ACE_Message_Block *> at the end of the queue. More...
 
virtual int enqueue_head_i (ACE_Message_Block *new_item)
 Enqueue an <ACE_Message_Block *> at the head of the queue. More...
 
virtual int dequeue_prio_i (ACE_Message_Block *&dequeued)
 
virtual int dequeue_tail_i (ACE_Message_Block *&first_item)
 
virtual int dequeue_deadline_i (ACE_Message_Block *&first_item)
 
virtual bool is_full_i (void)
 True if queue is full, else false. More...
 
virtual bool is_empty_i (void)
 True if queue is empty, else false. More...
 
virtual int deactivate_i (int pulse=0)
 
virtual int activate_i (void)
 Activate the queue. More...
 
virtual int wait_not_full_cond (ACE_Time_Value *timeout)
 Wait for the queue to become non-full. More...
 
virtual int wait_not_empty_cond (ACE_Time_Value *timeout)
 Wait for the queue to become non-empty. More...
 
virtual int signal_enqueue_waiters (void)
 Inform any threads waiting to enqueue that they can procede. More...
 
virtual int signal_dequeue_waiters (void)
 Inform any threads waiting to dequeue that they can procede. More...
 

Protected Attributes

ACE_Message_Blockpending_head_
 Pointer to head of the pending messages. More...
 
ACE_Message_Blockpending_tail_
 Pointer to tail of the pending messages. More...
 
ACE_Message_Blocklate_head_
 Pointer to head of the late messages. More...
 
ACE_Message_Blocklate_tail_
 Pointer to tail of the late messages. More...
 
ACE_Message_Blockbeyond_late_head_
 Pointer to head of the beyond late messages. More...
 
ACE_Message_Blockbeyond_late_tail_
 Pointer to tail of the beyond late messages. More...
 
ACE_Dynamic_Message_Strategymessage_strategy_
 Pointer to a dynamic priority evaluation function. More...
 
- Protected Attributes inherited from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >
ACE_Message_Blockhead_
 Pointer to head of ACE_Message_Block list. More...
 
ACE_Message_Blocktail_
 Pointer to tail of ACE_Message_Block list. More...
 
size_t low_water_mark_
 Lowest number before unblocking occurs. More...
 
size_t high_water_mark_
 Greatest number of bytes before blocking. More...
 
size_t cur_bytes_
 Current number of bytes in the queue. More...
 
size_t cur_length_
 Current length of messages in the queue. More...
 
size_t cur_count_
 Current number of messages in the queue. More...
 
ACE_Notification_Strategynotification_strategy_
 The notification strategy used when a new message is enqueued. More...
 
ACE_SYNCH_MUTEX_T lock_
 Protect queue from concurrent access. More...
 
ACE_Condition_Attributes_T
< TIME_POLICY > 
cond_attr_
 Attributes to initialize conditions with. More...
 
ACE_SYNCH_CONDITION_T not_empty_cond_
 Used to make threads sleep until the queue is no longer empty. More...
 
ACE_SYNCH_CONDITION_T not_full_cond_
 Used to make threads sleep until the queue is no longer full. More...
 
TIME_POLICY time_policy_
 The policy to return the current time of day. More...
 
- Protected Attributes inherited from ACE_Message_Queue_Base
int state_
 

Private Member Functions

void operator= (const ACE_Dynamic_Message_Queue< _ACE_SYNCH, TIME_POLICY > &)
 
 ACE_Dynamic_Message_Queue (const ACE_Dynamic_Message_Queue< _ACE_SYNCH, TIME_POLICY > &)
 
virtual int peek_dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout=0)
 Private method to hide public base class method: just calls base class method. More...
 

Additional Inherited Members

- Public Types inherited from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >
typedef
ACE_Message_Queue_Iterator
< ACE_SYNCH_USE, TIME_POLICY > 
ITERATOR
 
typedef
ACE_Message_Queue_Reverse_Iterator
< ACE_SYNCH_USE, TIME_POLICY > 
REVERSE_ITERATOR
 
- Public Types inherited from ACE_Message_Queue_Base
enum  {
  DEFAULT_HWM = 16 * 1024, DEFAULT_LWM = 16 * 1024, ACTIVATED = 1, DEACTIVATED = 2,
  PULSED = 3
}
 

Detailed Description

template<ACE_SYNCH_DECL, class TIME_POLICY = ACE_System_Time_Policy>
class ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >

A derived class which adapts the ACE_Message_Queue class in order to maintain dynamic priorities for enqueued <ACE_Message_Blocks> and manage the queue order according to these dynamic priorities.

The messages in the queue are managed so as to preserve a logical ordering with minimal overhead per enqueue and dequeue operation. For this reason, the actual order of messages in the linked list of the queue may differ from their priority order. As time passes, a message may change from pending status to late status, and eventually to beyond late status. To minimize reordering overhead under this design force, three separate boundaries are maintained within the linked list of messages. Messages are dequeued preferentially from the head of the pending portion, then the head of the late portion, and finally from the head of the beyond late portion. In this way, only the boundaries need to be maintained (which can be done efficiently, as aging messages maintain the same linked list order as they progress from one status to the next), with no reordering of the messages themselves, while providing correct priority ordered dequeueing semantics. Head and tail enqueue methods inherited from ACE_Message_Queue are made private to prevent out-of-order messages from confusing management of the various portions of the queue. Messages in the pending portion of the queue whose priority becomes late (according to the specific dynamic strategy) advance into the late portion of the queue. Messages in the late portion of the queue whose priority becomes later than can be represented advance to the beyond_late portion of the queue. These behaviors support a limited schedule overrun, with pending messages prioritized ahead of late messages, and late messages ahead of beyond late messages. These behaviors can be modified in derived classes by providing alternative definitions for the appropriate virtual methods. When filled with messages, the queue's linked list should look like: H T | | B - B - B - B - L - L - L - P - P - P - P - P | | | | | | BH BT LH LT PH PT Where the symbols are as follows: H = Head of the entire list T = Tail of the entire list B = Beyond late message BH = Beyond late messages Head BT = Beyond late messages Tail L = Late message LH = Late messages Head LT = Late messages Tail P = Pending message PH = Pending messages Head PT = Pending messages Tail Caveat: the virtual methods enqueue_tail, enqueue_head, and peek_dequeue_head have semantics for the static message queues that cannot be guaranteed for dynamic message queues. The peek_dequeue_head method just calls the base class method, while the two enqueue methods call the priority enqueue method. The order of messages in the dynamic queue is a function of message deadlines and how long they are in the queues. You can manipulate these in some cases to ensure the correct semantics, but that is not a very stable or portable approach (discouraged).

Constructor & Destructor Documentation

template<ACE_SYNCH_DECL , class TIME_POLICY >
ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::ACE_Dynamic_Message_Queue ( ACE_Dynamic_Message_Strategy message_strategy,
size_t  hwm = ACE_Message_Queue_Base::DEFAULT_HWM,
size_t  lwm = ACE_Message_Queue_Base::DEFAULT_LWM,
ACE_Notification_Strategy ns = 0 
)
template<ACE_SYNCH_DECL , class TIME_POLICY >
ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::~ACE_Dynamic_Message_Queue ( void  )
virtual

Close down the message queue and release all resources.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::ACE_Dynamic_Message_Queue ( const ACE_Dynamic_Message_Queue< _ACE_SYNCH, TIME_POLICY > &  )
private

Member Function Documentation

template<ACE_SYNCH_DECL , class TIME_POLICY >
int ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::dequeue_head ( ACE_Message_Block *&  first_item,
ACE_Time_Value timeout = 0 
)
virtual

Dequeue and return the <ACE_Message_Block *> at the head of the queue. Returns -1 on failure, else the number of items still on the queue.

Reimplemented from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY >
int ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::dequeue_head_i ( ACE_Message_Block *&  first_item)
protectedvirtual

Dequeue and return the <ACE_Message_Block *> at the head of the logical queue. Attempts first to dequeue from the pending portion of the queue, or if that is empty from the late portion, or if that is empty from the beyond late portion, or if that is empty just sets the passed pointer to zero and returns -1.

Reimplemented from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY >
void ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::dump ( void  ) const
virtual

Dump the state of the queue.

Reimplemented from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY >
int ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::enqueue_head ( ACE_Message_Block new_item,
ACE_Time_Value timeout = 0 
)
virtual

Just call priority enqueue method: head enqueue semantics for dynamic message queues are unstable: the message may or may not be where it was placed after the queue is refreshed prior to the next enqueue or dequeue operation.

Reimplemented from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY >
int ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::enqueue_i ( ACE_Message_Block new_item)
protectedvirtual

Enqueue an <ACE_Message_Block *> in accordance with its priority. priority may be dynamic or static or a combination or both It calls the priority evaluation function passed into the Dynamic Message Queue constructor to update the priorities of all enqueued messages.

Reimplemented from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY >
int ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::enqueue_tail ( ACE_Message_Block new_item,
ACE_Time_Value timeout = 0 
)
virtual

Just call priority enqueue method: tail enqueue semantics for dynamic message queues are unstable: the message may or may not be where it was placed after the queue is refreshed prior to the next enqueue or dequeue operation.

Reimplemented from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
void ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::operator= ( const ACE_Dynamic_Message_Queue< _ACE_SYNCH, TIME_POLICY > &  )
private
template<ACE_SYNCH_DECL , class TIME_POLICY >
int ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::peek_dequeue_head ( ACE_Message_Block *&  first_item,
ACE_Time_Value timeout = 0 
)
privatevirtual

Private method to hide public base class method: just calls base class method.

Reimplemented from ACE_Message_Queue< ACE_SYNCH_USE, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY >
int ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::refresh_late_queue ( const ACE_Time_Value current_time)
protectedvirtual

Refresh the late queue using the strategy specific priority status function.

template<ACE_SYNCH_DECL , class TIME_POLICY >
int ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::refresh_pending_queue ( const ACE_Time_Value current_time)
protectedvirtual

Refresh the pending queue using the strategy specific priority status function.

template<ACE_SYNCH_DECL , class TIME_POLICY >
int ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::refresh_queue ( const ACE_Time_Value current_time)
protectedvirtual

Refresh the queue using the strategy specific priority status function.

template<ACE_SYNCH_DECL , class TIME_POLICY >
int ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::remove_messages ( ACE_Message_Block *&  list_head,
ACE_Message_Block *&  list_tail,
u_int  status_flags 
)
virtual

Detach all messages with status given in the passed flags from the queue and return them by setting passed head and tail pointers to the linked list they comprise. This method is intended primarily as a means of periodically harvesting messages that have missed their deadlines, but is available in its most general form. All messages are returned in priority order, from head to tail, as of the time this method was called.

template<ACE_SYNCH_DECL , class TIME_POLICY >
int ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::sublist_enqueue_i ( ACE_Message_Block new_item,
const ACE_Time_Value current_time,
ACE_Message_Block *&  sublist_head,
ACE_Message_Block *&  sublist_tail,
ACE_Dynamic_Message_Strategy::Priority_Status  status 
)
protectedvirtual

Enqueue a message in priority order within a given priority status sublist.

Member Data Documentation

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Message_Block* ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::beyond_late_head_
protected

Pointer to head of the beyond late messages.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Message_Block* ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::beyond_late_tail_
protected

Pointer to tail of the beyond late messages.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Message_Block* ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::late_head_
protected

Pointer to head of the late messages.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Message_Block* ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::late_tail_
protected

Pointer to tail of the late messages.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Dynamic_Message_Strategy& ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::message_strategy_
protected

Pointer to a dynamic priority evaluation function.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Message_Block* ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::pending_head_
protected

Pointer to head of the pending messages.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Message_Block* ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::pending_tail_
protected

Pointer to tail of the pending messages.


The documentation for this class was generated from the following files: