Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Message_Queue Class Template Reference

A threaded message queueing facility, modeled after the queueing facilities in System V STREAMs. More...

#include <Message_Queue_T.h>

Inheritance diagram for ACE_Message_Queue

Inheritance graph
[legend]
Collaboration diagram for ACE_Message_Queue:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Message_Queue_Iterator<
ACE_SYNCH_USE> 
ITERATOR
typedef ACE_Message_Queue_Reverse_Iterator<
ACE_SYNCH_USE> 
REVERSE_ITERATOR

Public Methods

 ACE_Message_Queue (size_t high_water_mark = ACE_Message_Queue_Base::DEFAULT_HWM, size_t low_water_mark = ACE_Message_Queue_Base::DEFAULT_LWM, ACE_Notification_Strategy * = 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 * = 0)
virtual int close (void)
 Close down the message queue and release all resources.

virtual ~ACE_Message_Queue (void)
 Close down the message queue and release all resources.

virtual int peek_dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout = 0)
virtual int enqueue_prio (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 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)
virtual int dequeue (ACE_Message_Block *&first_item, ACE_Time_Value *timeout = 0)
 This method is an alias for the following <dequeue_head> method.

virtual int dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout = 0)
virtual int is_full (void)
 True if queue is full, else false.

virtual int is_empty (void)
 True if queue is empty, else false.

virtual size_t message_bytes (void)
virtual size_t message_length (void)
virtual size_t message_count (void)
virtual void message_bytes (size_t new_size)
virtual void message_length (size_t new_length)
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 deactivated (void)
 Returns true if <deactivated_> is enabled.

virtual int notify (void)
virtual ACE_Notification_Strategynotification_strategy (void)
virtual void notification_strategy (ACE_Notification_Strategy *s)
virtual ACE_SYNCH_MUTEX_T& lock (void)
 Returns a reference to the lock used by the .

virtual void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Methods

virtual int enqueue_i (ACE_Message_Block *new_item)
 Enqueue an in accordance with its priority.

virtual int enqueue_tail_i (ACE_Message_Block *new_item)
 Enqueue an at the end of the queue.

virtual int enqueue_head_i (ACE_Message_Block *new_item)
 Enqueue an at the head of the queue.

virtual int dequeue_head_i (ACE_Message_Block *&first_item)
 Dequeue and return the at the head of the queue.

virtual int is_full_i (void)
 True if queue is full, else false.

virtual int is_empty_i (void)
 True if queue is empty, else false.

virtual int deactivate_i (void)
 Deactivate the queue.

virtual int activate_i (void)
 Activate the queue.

virtual int wait_not_full_cond (ACE_Guard<ACE_SYNCH_MUTEX_T> &mon, ACE_Time_Value *timeout)
 Wait for the queue to become non-full.

virtual int wait_not_empty_cond (ACE_Guard<ACE_SYNCH_MUTEX_T> &mon, ACE_Time_Value *timeout)
 Wait for the queue to become non-empty.

virtual int signal_enqueue_waiters (void)
 Inform any threads waiting to enqueue that they can procede.

virtual int signal_dequeue_waiters (void)
 Inform any threads waiting to dequeue that they can procede.


Protected Attributes

ACE_Message_Blockhead_
 Pointer to head of ACE_Message_Block list.

ACE_Message_Blocktail_
 Pointer to tail of ACE_Message_Block list.

size_t low_water_mark_
 Lowest number before unblocking occurs.

size_t high_water_mark_
 Greatest number of bytes before blocking.

size_t cur_bytes_
 Current number of bytes in the queue.

size_t cur_length_
 Current length of messages in the queue.

size_t cur_count_
 Current number of messages in the queue.

int deactivated_
 Indicates that the queue is inactive.

ACE_Notification_Strategynotification_strategy_
 The notification strategy used when a new message is enqueued.

ACE_SYNCH_MUTEX_T lock_
 Protect queue from concurrent access.

ACE_SYNCH_CONDITION_T not_empty_cond_
 Used to make threads sleep until the queue is no longer empty.

ACE_SYNCH_CONDITION_T not_full_cond_
 Used to make threads sleep until the queue is no longer full.


Private Methods

void operator= (const ACE_Message_Queue< _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T > &)
 ACE_Message_Queue (const ACE_Message_Queue< _ACE_SYNCH_MUTEX_T, _ACE_SYNCH_CONDITION_T > &)

Friends

class  ACE_Message_Queue_Iterator< ACE_SYNCH_USE >
class  ACE_Message_Queue_Reverse_Iterator< ACE_SYNCH_USE >

Detailed Description

template<ACE_SYNCH_DECL> template class ACE_Message_Queue

A threaded message queueing facility, modeled after the queueing facilities in System V STREAMs.

An is the central queueing facility for messages in the ACE framework. If is then all operations are thread-safe. Otherwise, if it's then there's no locking overhead.


Member Typedef Documentation

template<ACE_SYNCH_DECL>
typedef ACE_Message_Queue_Iterator<ACE_SYNCH_USE> ACE_Message_Queue<>::ITERATOR
 

template<ACE_SYNCH_DECL>
typedef ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE> ACE_Message_Queue<>::REVERSE_ITERATOR
 


Constructor & Destructor Documentation

template<ACE_SYNCH_DECL>
ACE_Message_Queue<>::ACE_Message_Queue<> ( size_t high_water_mark = ACE_Message_Queue_Base::DEFAULT_HWM,
size_t low_water_mark = ACE_Message_Queue_Base::DEFAULT_LWM,
ACE_Notification_Strategy * ns = 0 )
 

Initialize an . The <high_water_mark> determines how many bytes can be stored in a queue before it's considered "full." Supplier threads must block until the queue is no longer full. The <low_water_mark> determines how many bytes must be in the queue before supplier threads are allowed to enqueue additional s. By default, the <high_water_mark> equals the <low_water_mark>, which means that suppliers will be able to enqueue new messages as soon as a consumer removes any message from the queue. Making the <low_water_mark> smaller than the <high_water_mark> forces consumers to drain more messages from the queue before suppliers can enqueue new messages, which can minimize the "silly window syndrome."

template<ACE_SYNCH_DECL>
ACE_Message_Queue<>::~ACE_Message_Queue<> ( void ) [virtual]
 

Close down the message queue and release all resources.

template<ACE_SYNCH_DECL>
ACE_Message_Queue<>::ACE_Message_Queue<> ( const ACE_Message_Queue< _ACE_SYNCH_MUTEX_T,_ACE_SYNCH_CONDITION_T >& ) [private]
 


Member Function Documentation

template<ACE_SYNCH_DECL>
ACE_INLINE int ACE_Message_Queue< ACE_SYNCH_USE >::activate ( void ) [virtual]
 

Reactivate the queue so that threads can enqueue and dequeue messages again. Returns WAS_INACTIVE if queue was inactive before the call and WAS_ACTIVE if queue was active before the call.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::activate_i ( void ) [protected, virtual]
 

Activate the queue.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::close ( void ) [virtual]
 

Close down the message queue and release all resources.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
ACE_INLINE int ACE_Message_Queue< ACE_SYNCH_USE >::deactivate ( void ) [virtual]
 

Deactivate the queue and wakeup all threads waiting on the queue so they can continue. No messages are removed from the queue, however. Any other operations called until the queue is activated again will immediately return -1 with <errno> == ESHUTDOWN. Returns WAS_INACTIVE if queue was inactive before the call and WAS_ACTIVE if queue was active before the call.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::deactivate_i ( void ) [protected, virtual]
 

Deactivate the queue.

template<ACE_SYNCH_DECL>
ACE_INLINE int ACE_Message_Queue< ACE_SYNCH_USE >::deactivated ( void ) [virtual]
 

Returns true if <deactivated_> is enabled.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
ACE_INLINE int ACE_Message_Queue< ACE_SYNCH_USE >::dequeue ( ACE_Message_Block *& first_item,
ACE_Time_Value * timeout = 0 ) [virtual]
 

This method is an alias for the following <dequeue_head> method.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::dequeue_head ( ACE_Message_Block *& first_item,
ACE_Time_Value * timeout = 0 ) [virtual]
 

Dequeue and return the at the head of the queue. Note that <timeout> uses <{absolute}> time rather than <{relative}> time. If the <timeout> elapses without receiving a message -1 is returned and <errno> is set to <EWOULDBLOCK>. If the queue is deactivated -1 is returned and <errno> is set to <ESHUTDOWN>. Otherwise, returns -1 on failure, else the number of items still on the queue.

Reimplemented from ACE_Message_Queue_Base.

Reimplemented in ACE_Dynamic_Message_Queue.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::dequeue_head_i ( ACE_Message_Block *& first_item ) [protected, virtual]
 

Dequeue and return the at the head of the queue.

Reimplemented in ACE_Dynamic_Message_Queue.

template<ACE_SYNCH_DECL>
void ACE_Message_Queue<>::dump ( void ) const [virtual]
 

Dump the state of an object.

Reimplemented from ACE_Message_Queue_Base.

Reimplemented in ACE_Dynamic_Message_Queue.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::enqueue ( ACE_Message_Block * new_item,
ACE_Time_Value * timeout = 0 ) [virtual]
 

This is an alias for <enqueue_prio>. It's only here for backwards compatibility and will go away in a subsequent release. Please use <enqueue_prio> instead. Note that <timeout> uses <{absolute}> time rather than <{relative}> time.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::enqueue_head ( ACE_Message_Block * new_item,
ACE_Time_Value * timeout = 0 ) [virtual]
 

Enqueue an at the head of the queue. Note that <timeout> uses <{absolute}> time rather than <{relative}> time. If the <timeout> elapses without receiving a message -1 is returned and <errno> is set to <EWOULDBLOCK>. If the queue is deactivated -1 is returned and <errno> is set to <ESHUTDOWN>. Otherwise, returns -1 on failure, else the number of items still on the queue.

Reimplemented in ACE_Dynamic_Message_Queue.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::enqueue_head_i ( ACE_Message_Block * new_item ) [protected, virtual]
 

Enqueue an at the head of the queue.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::enqueue_i ( ACE_Message_Block * new_item ) [protected, virtual]
 

Enqueue an in accordance with its priority.

Reimplemented in ACE_Dynamic_Message_Queue.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::enqueue_prio ( ACE_Message_Block * new_item,
ACE_Time_Value * timeout = 0 ) [virtual]
 

Enqueue an into the <Message_Queue> in accordance with its <msg_priority> (0 is lowest priority). FIFO order is maintained when messages of the same priority are inserted consecutively. Note that <timeout> uses <{absolute}> time rather than <{relative}> time. If the <timeout> elapses without receiving a message -1 is returned and <errno> is set to <EWOULDBLOCK>. If the queue is deactivated -1 is returned and <errno> is set to <ESHUTDOWN>. Otherwise, returns -1 on failure, else the number of items still on the queue.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::enqueue_tail ( ACE_Message_Block * new_item,
ACE_Time_Value * timeout = 0 ) [virtual]
 

Enqueue an at the end of the queue. Note that <timeout> uses <{absolute}> time rather than <{relative}> time. If the <timeout> elapses without receiving a message -1 is returned and <errno> is set to <EWOULDBLOCK>. If the queue is deactivated -1 is returned and <errno> is set to <ESHUTDOWN>. Otherwise, returns -1 on failure, else the number of items still on the queue.

Reimplemented from ACE_Message_Queue_Base.

Reimplemented in ACE_Dynamic_Message_Queue.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::enqueue_tail_i ( ACE_Message_Block * new_item ) [protected, virtual]
 

Enqueue an at the end of the queue.

template<ACE_SYNCH_DECL>
ACE_INLINE void ACE_Message_Queue< ACE_SYNCH_USE >::high_water_mark ( size_t hwm ) [virtual]
 

Set the high watermark, which determines how many bytes can be stored in a queue before it's considered "full."

template<ACE_SYNCH_DECL>
ACE_INLINE size_t ACE_Message_Queue< ACE_SYNCH_USE >::high_water_mark ( void ) [virtual]
 

Get high watermark.

template<ACE_SYNCH_DECL>
ACE_INLINE int ACE_Message_Queue< ACE_SYNCH_USE >::is_empty ( void ) [virtual]
 

True if queue is empty, else false.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
ACE_INLINE int ACE_Message_Queue< ACE_SYNCH_USE >::is_empty_i ( void ) [protected, virtual]
 

True if queue is empty, else false.

template<ACE_SYNCH_DECL>
ACE_INLINE int ACE_Message_Queue< ACE_SYNCH_USE >::is_full ( void ) [virtual]
 

True if queue is full, else false.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
ACE_INLINE int ACE_Message_Queue< ACE_SYNCH_USE >::is_full_i ( void ) [protected, virtual]
 

True if queue is full, else false.

template<ACE_SYNCH_DECL>
ACE_SYNCH_MUTEX_T & ACE_Message_Queue<>::lock ( void ) [inline, virtual]
 

Returns a reference to the lock used by the .

template<ACE_SYNCH_DECL>
ACE_INLINE void ACE_Message_Queue< ACE_SYNCH_USE >::low_water_mark ( size_t lwm ) [virtual]
 

Set the low watermark, which determines how many bytes must be in the queue before supplier threads are allowed to enqueue additional s.

template<ACE_SYNCH_DECL>
ACE_INLINE size_t ACE_Message_Queue< ACE_SYNCH_USE >::low_water_mark ( void ) [virtual]
 

Get low watermark.

template<ACE_SYNCH_DECL>
void ACE_Message_Queue<>::message_bytes ( size_t new_size ) [virtual]
 

New value of the number of total bytes on the queue, i.e., sum of the message block sizes.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
ACE_INLINE size_t ACE_Message_Queue< ACE_SYNCH_USE >::message_bytes ( void ) [virtual]
 

Number of total bytes on the queue, i.e., sum of the message block sizes.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
ACE_INLINE size_t ACE_Message_Queue< ACE_SYNCH_USE >::message_count ( void ) [virtual]
 

Number of total messages on the queue.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
void ACE_Message_Queue<>::message_length ( size_t new_length ) [virtual]
 

New value of the number of total length on the queue, i.e., sum of the message block lengths.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
ACE_INLINE size_t ACE_Message_Queue< ACE_SYNCH_USE >::message_length ( void ) [virtual]
 

Number of total length on the queue, i.e., sum of the message block lengths.

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
ACE_INLINE void ACE_Message_Queue< ACE_SYNCH_USE >::notification_strategy ( ACE_Notification_Strategy * s ) [virtual]
 

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
ACE_INLINE ACE_Notification_Strategy * ACE_Message_Queue< ACE_SYNCH_USE >::notification_strategy ( void ) [virtual]
 

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::notify ( void ) [virtual]
 

This hook is automatically invoked by <enqueue_head>, <enqueue_tail>, and <enqueue_prio> when a new item is inserted into the queue. Subclasses can override this method to perform specific notification strategies (e.g., signaling events for a <WFMO_Reactor>, notifying a <Reactor>, etc.). In a multi-threaded application with concurrent consumers, there is no guarantee that the queue will be still be non-empty by the time the notification occurs.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::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]
 

Initialize an . The <high_water_mark> determines how many bytes can be stored in a queue before it's considered "full." Supplier threads must block until the queue is no longer full. The <low_water_mark> determines how many bytes must be in the queue before supplier threads are allowed to enqueue additional s. By default, the <high_water_mark> equals the <low_water_mark>, which means that suppliers will be able to enqueue new messages as soon as a consumer removes any message from the queue. Making the <low_water_mark> smaller than the <high_water_mark> forces consumers to drain more messages from the queue before suppliers can enqueue new messages, which can minimize the "silly window syndrome."

template<ACE_SYNCH_DECL>
void ACE_Message_Queue<>::operator= ( const ACE_Message_Queue< _ACE_SYNCH_MUTEX_T,_ACE_SYNCH_CONDITION_T >& ) [private]
 

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::peek_dequeue_head ( ACE_Message_Block *& first_item,
ACE_Time_Value * timeout = 0 ) [virtual]
 

Retrieve the first without removing it. Note that <timeout> uses <{absolute}> time rather than <{relative}> time. If the <timeout> elapses without receiving a message -1 is returned and <errno> is set to <EWOULDBLOCK>. If the queue is deactivated -1 is returned and <errno> is set to <ESHUTDOWN>. Otherwise, returns -1 on failure, else the number of items still on the queue.

Reimplemented from ACE_Message_Queue_Base.

Reimplemented in ACE_Dynamic_Message_Queue.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::signal_dequeue_waiters ( void ) [protected, virtual]
 

Inform any threads waiting to dequeue that they can procede.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::signal_enqueue_waiters ( void ) [protected, virtual]
 

Inform any threads waiting to enqueue that they can procede.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::wait_not_empty_cond ( ACE_Guard< ACE_SYNCH_MUTEX_T >& mon,
ACE_Time_Value * timeout ) [protected, virtual]
 

Wait for the queue to become non-empty.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::wait_not_full_cond ( ACE_Guard< ACE_SYNCH_MUTEX_T >& mon,
ACE_Time_Value * timeout ) [protected, virtual]
 

Wait for the queue to become non-full.


Friends And Related Function Documentation

template<ACE_SYNCH_DECL>
class ACE_Message_Queue_Iterator [friend]
 

template<ACE_SYNCH_DECL>
class ACE_Message_Queue_Reverse_Iterator [friend]
 


Member Data Documentation

template<ACE_SYNCH_DECL>
ACE_Message_Queue<>::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Message_Queue_Base.

Reimplemented in ACE_Dynamic_Message_Queue.

template<ACE_SYNCH_DECL>
size_t ACE_Message_Queue<>::cur_bytes_ [protected]
 

Current number of bytes in the queue.

template<ACE_SYNCH_DECL>
size_t ACE_Message_Queue<>::cur_count_ [protected]
 

Current number of messages in the queue.

template<ACE_SYNCH_DECL>
size_t ACE_Message_Queue<>::cur_length_ [protected]
 

Current length of messages in the queue.

template<ACE_SYNCH_DECL>
int ACE_Message_Queue<>::deactivated_ [protected]
 

Indicates that the queue is inactive.

template<ACE_SYNCH_DECL>
ACE_Message_Block * ACE_Message_Queue<>::head_ [protected]
 

Pointer to head of ACE_Message_Block list.

template<ACE_SYNCH_DECL>
size_t ACE_Message_Queue<>::high_water_mark_ [protected]
 

Greatest number of bytes before blocking.

template<ACE_SYNCH_DECL>
ACE_SYNCH_MUTEX_T ACE_Message_Queue<>::lock_ [protected]
 

Protect queue from concurrent access.

template<ACE_SYNCH_DECL>
size_t ACE_Message_Queue<>::low_water_mark_ [protected]
 

Lowest number before unblocking occurs.

template<ACE_SYNCH_DECL>
ACE_SYNCH_CONDITION_T ACE_Message_Queue<>::not_empty_cond_ [protected]
 

Used to make threads sleep until the queue is no longer empty.

template<ACE_SYNCH_DECL>
ACE_SYNCH_CONDITION_T ACE_Message_Queue<>::not_full_cond_ [protected]
 

Used to make threads sleep until the queue is no longer full.

template<ACE_SYNCH_DECL>
ACE_Notification_Strategy * ACE_Message_Queue<>::notification_strategy_ [protected]
 

The notification strategy used when a new message is enqueued.

template<ACE_SYNCH_DECL>
ACE_Message_Block * ACE_Message_Queue<>::tail_ [protected]
 

Pointer to tail of ACE_Message_Block list.


The documentation for this class was generated from the following files:
Generated at Sat Dec 1 11:03:05 2001 for ACE by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000