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

# ACE_Message_Queue_Ex Class Template Reference

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

`#include <Message_Queue_T.h>`

Collaboration diagram for ACE_Message_Queue_Ex:

[legend]
List of all members.

## Public Types
enum | { DEFAULT_PRIORITY = 0 }
## Public Methods
| ACE_Message_Queue_Ex (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. More...
virtual | ~ACE_Message_Queue_Ex (void)
| Close down the message queue and release all resources. More...
virtual int | flush (void)
| Release all resources from the message queue but do not mark it as deactivated. This method holds the queue lock during this operation. Returns the number of messages flushed. More...
virtual int | flush_i (void)
| Release all resources from the message queue but do not mark it as deactivated. This method does not hold the queue lock during this operation, i.e., it assume the lock is held externally. Returns the number of messages flushed. More...
virtual int | peek_dequeue_head (ACE_MESSAGE_TYPE *&first_item, ACE_Time_Value *timeout=0)
virtual int | enqueue_prio (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout=0)
virtual int | enqueue_deadline (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout=0)
virtual int | enqueue (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout=0)
virtual int | enqueue_tail (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout=0)
virtual int | enqueue_head (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *timeout=0)
virtual int | dequeue (ACE_MESSAGE_TYPE *&first_item, ACE_Time_Value *timeout=0)
| This method is an alias for the following <dequeue_head> method. More...
virtual int | dequeue_head (ACE_MESSAGE_TYPE *&first_item, ACE_Time_Value *timeout=0)
virtual int | dequeue_prio (ACE_MESSAGE_TYPE *&dequeued, ACE_Time_Value *timeout=0)
virtual int | dequeue_tail (ACE_MESSAGE_TYPE *&dequeued, ACE_Time_Value *timeout=0)
virtual int | dequeue_deadline (ACE_MESSAGE_TYPE *&dequeued, ACE_Time_Value *timeout=0)
virtual int | is_full (void)
| True if queue is full, else false. More...
virtual int | is_empty (void)
| True if queue is empty, else false. More...
virtual size_t | message_bytes (void)
virtual size_t | message_length (void)
virtual int | 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 | pulse (void)
virtual int | state (void)
| Returns the current state of the queue, which can be one of ACTIVATED, DEACTIVATED, or PULSED. More...
virtual int | deactivated (void)
| Returns true if the state of the queue is DEACTIVATED, but false if the queue's state is ACTIVATED or PULSED. More...
virtual int | notify (void)
virtual ACE_Notification_Strategy * | notification_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...
virtual ACE_SYNCH_MUTEX_T & | lock (void)
| Returns a reference to the lock used by the <ACE_Message_Queue_Ex>. More...
virtual void | dump (void) const
| Dump the state of an object. More...
## Public Attributes
| ACE_ALLOC_HOOK_DECLARE
| Declare the dynamic allocation hooks. More...
## Private Attributes
ACE_Message_Queue< ACE_SYNCH_USE > | queue_
| Implement this via an <ACE_Message_Queue>. More...

## Detailed Description

### template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL>
class ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >

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

An <ACE_Message_Queue_Ex> is a strongly-typed version of the <ACE_Message_Queue>. If <ACE_SYNCH_DECL> is <ACE_MT_SYNCH> then all operations are thread-safe. Otherwise, if it's <ACE_NULL_SYNCH> then there's no locking overhead.

## Member Enumeration Documentation

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
anonymous enum

  | Enumeration values:
  DEFAULT_PRIORITY |

## Constructor & Destructor Documentation

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::ACE_Message_Queue_Ex | ( | size_t | hwm = ACE_Message_Queue_Base::DEFAULT_HWM,
|  | size_t | lwm = ACE_Message_Queue_Base::DEFAULT_LWM,
|  | ACE_Notification_Strategy * | ns = 0
| ) |

| Initialize an <ACE_Message_Queue>. 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 <ACE_Message_Block>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<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::~ACE_Message_Queue_Ex | ( | void |  | ) | `[virtual]`

| Close down the message queue and release all resources.

## Member Function Documentation

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::activate | ( | void |  | ) | `[virtual]`

| Reactivate the queue so that threads can enqueue and dequeue messages again. Returns the state of the queue before the call.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::close | ( | void |  | ) | `[virtual]`

| Close down the message queue and release all resources.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::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.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::deactivated | ( | void |  | ) | `[virtual]`

| Returns true if the state of the queue is DEACTIVATED, but false if the queue's state is ACTIVATED or PULSED.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::dequeue | ( | ACE_MESSAGE_TYPE *& | first_item,
|  | ACE_Time_Value * | timeout = 0
| ) | `[virtual]`

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

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::dequeue_deadline | ( | ACE_MESSAGE_TYPE *& | dequeued,
|  | ACE_Time_Value * | timeout = 0
| ) | `[virtual]`

| Dequeue and return the <ACE_Message_Block *> with the lowest deadline time. 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<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::dequeue_head | ( | ACE_MESSAGE_TYPE *& | first_item,
|  | ACE_Time_Value * | timeout = 0
| ) | `[virtual]`

| Dequeue and return the <ACE_Message_Block *> 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.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::dequeue_prio | ( | ACE_MESSAGE_TYPE *& | dequeued,
|  | ACE_Time_Value * | timeout = 0
| ) | `[virtual]`

| Dequeue and return the <ACE_Message_Block *> that has the lowest priority. 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<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::dequeue_tail | ( | ACE_MESSAGE_TYPE *& | dequeued,
|  | ACE_Time_Value * | timeout = 0
| ) | `[virtual]`

| Dequeue and return the <ACE_Message_Block *> at the tail 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.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
void ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::dump | ( | void |  | ) | const`[virtual]`

| Dump the state of an object.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::enqueue | ( | ACE_MESSAGE_TYPE * | 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.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::enqueue_deadline | ( | ACE_MESSAGE_TYPE * | new_item,
|  | ACE_Time_Value * | timeout = 0
| ) | `[virtual]`

| Enqueue an <ACE_Message_Block *> into the <Message_Queue> in accordance with its <msg_deadline_time>. FIFO order is maintained when messages of the same deadline time 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<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::enqueue_head | ( | ACE_MESSAGE_TYPE * | new_item,
|  | ACE_Time_Value * | timeout = 0
| ) | `[virtual]`

| Enqueue an <ACE_Message_Block *> 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.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::enqueue_prio | ( | ACE_MESSAGE_TYPE * | new_item,
|  | ACE_Time_Value * | timeout = 0
| ) | `[virtual]`

| Enqueue an <ACE_Message_Block *> 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<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::enqueue_tail | ( | ACE_MESSAGE_TYPE * | new_item,
|  | ACE_Time_Value * | timeout = 0
| ) | `[virtual]`

| Enqueue an <ACE_Message_Block *> 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.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::flush | ( | void |  | ) | `[virtual]`

| Release all resources from the message queue but do not mark it as deactivated. This method holds the queue lock during this operation. Returns the number of messages flushed.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::flush_i | ( | void |  | ) | `[virtual]`

| Release all resources from the message queue but do not mark it as deactivated. This method does not hold the queue lock during this operation, i.e., it assume the lock is held externally. Returns the number of messages flushed.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE void ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::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<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE size_t ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::high_water_mark | ( | void |  | ) | `[virtual]`

| Get high watermark.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::is_empty | ( | void |  | ) | `[virtual]`

| True if queue is empty, else false.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::is_full | ( | void |  | ) | `[virtual]`

| True if queue is full, else false.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
virtual ACE_SYNCH_MUTEX_T& ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::lock | ( | void |  | ) | `[inline, virtual]`

| Returns a reference to the lock used by the <ACE_Message_Queue_Ex>.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE void ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::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 <ACE_Message_Block>s.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE size_t ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::low_water_mark | ( | void |  | ) | `[virtual]`

| Get low watermark.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
void ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::message_bytes | ( | size_t | new_value | ) | `[virtual]`

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

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE size_t ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::message_bytes | ( | void |  | ) | `[virtual]`

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

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::message_count | ( | void |  | ) | `[virtual]`

| Number of total messages on the queue.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
void ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::message_length | ( | size_t | new_value | ) | `[virtual]`

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

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE size_t ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::message_length | ( | void |  | ) | `[virtual]`

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

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE void ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::notification_strategy | ( | ACE_Notification_Strategy * | s | ) | `[virtual]`

| Set the notification strategy for the <Message_Queue>.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE ACE_Notification_Strategy * ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::notification_strategy | ( | void |  | ) | `[virtual]`

| Get the notification strategy for the <Message_Queue>.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::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<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::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 <ACE_Message_Queue>. 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 <ACE_Message_Block>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<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::peek_dequeue_head | ( | ACE_MESSAGE_TYPE *& | first_item,
|  | ACE_Time_Value * | timeout = 0
| ) | `[virtual]`

| Retrieve the first <ACE_Message_Block> 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.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::pulse | ( | void |  | ) | `[virtual]`

  | Pulse the queue to wake up any waiting threads. Changes the queue state to PULSED; future enqueue/dequeue operations proceed as in ACTIVATED state. Return values:
  The | queue's state before this call.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_INLINE int ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, >::state | ( | void |  | ) | `[virtual]`

| Returns the current state of the queue, which can be one of ACTIVATED, DEACTIVATED, or PULSED.

## Member Data Documentation

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_Message_Queue_Ex::ACE_ALLOC_HOOK_DECLARE

| Declare the dynamic allocation hooks.

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_Message_Queue<ACE_SYNCH_USE> ACE_Message_Queue_Ex::queue_`[private]`

| Implement this via an <ACE_Message_Queue>.

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

- Message_Queue_T.h
- Message_Queue_T.cpp
- Message_Queue_T.i