ACE  6.3.3
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Friends | List of all members
ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY > Class Template Reference

A message queuing facility with parameterized synchronization capability. ACE_Message_Queue is modeled after the queueing facilities in System V STREAMs. More...

#include <Message_Queue_T.h>

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

Public Types

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
}
 

Public Member Functions

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)
 
virtual void dump (void) const
 Dump the state of an object. More...
 
Initialization methods
 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)
 
Enqueue and dequeue methods

The enqueue and dequeue methods accept a timeout value passed as an ACE_Time_Value *. In all cases, if the timeout pointer is 0, the caller will block until action is possible. If the timeout pointer is non-zero, the call will wait (if needed, subject to water mark settings) until the absolute time specified in the referenced ACE_Time_Value object is reached. If the time is reached before the desired action is possible, the method will return -1 with errno set to EWOULDBLOCK. Regardless of the timeout setting, however, these methods will also fail and return -1 when the queue is closed, deactivated, pulsed, or when a signal occurs.

See C++NPv2 Section 6.2 and APG Section 12.3 for a fuller treatment of ACE_Message_Queue, enqueueing, dequeueing, and how these operations are affected by queue state transitions.

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_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 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 dequeue_head() method. More...
 
virtual int dequeue_head (ACE_Message_Block *&first_item, ACE_Time_Value *timeout=0)
 
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)
 
Queue statistics methods
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 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)
 
Water mark (flow control) methods
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)
 
Activation and queue state methods

See C++NPv2 Section 6.2 and APG Section 12.3 for a fuller treatment of queue states and transitions and how the transitions affect message enqueueing and dequeueing operations.

virtual int deactivate (void)
 
virtual int activate (void)
 
virtual int pulse (void)
 
virtual int state (void)
 
virtual int deactivated (void)
 
Notification strategy methods
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_Base
 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...
 

Protected Member Functions

virtual int enqueue_i (ACE_Message_Block *new_item)
 Enqueue an <ACE_Message_Block *> in accordance with its priority. More...
 
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_head_i (ACE_Message_Block *&first_item)
 
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_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_Message_Queue< _ACE_SYNCH > &)
 Sends the size of the queue whenever it changes. More...
 
 ACE_Message_Queue (const ACE_Message_Queue< _ACE_SYNCH > &)
 

Friends

class ACE_Message_Queue_Iterator< ACE_SYNCH_USE, TIME_POLICY >
 
class ACE_Message_Queue_Reverse_Iterator< ACE_SYNCH_USE, TIME_POLICY >
 

Detailed Description

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

A message queuing facility with parameterized synchronization capability. ACE_Message_Queue is modeled after the queueing facilities in System V STREAMs.

ACE_Message_Queue is the primary queuing facility for messages in the ACE framework. It's one template argument parameterizes the queue's synchronization. The argument specifies a synchronization strategy. The two main strategies available for ACE_SYNCH_DECL are:

  1. ACE_MT_SYNCH: all operations are thread-safe
  2. ACE_NULL_SYNCH: no synchronization and no locking overhead

All data passing through ACE_Message_Queue is in the form of ACE_Message_Block objects.

See also
ACE_Message_Block.

Member Typedef Documentation

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
typedef ACE_Message_Queue_Iterator<ACE_SYNCH_USE, TIME_POLICY> ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::ITERATOR
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
typedef ACE_Message_Queue_Reverse_Iterator<ACE_SYNCH_USE, TIME_POLICY> ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::REVERSE_ITERATOR

Constructor & Destructor Documentation

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Message_Queue< ACE_SYNCH_DECL, 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 
)

Initialize an ACE_Message_Queue.

Parameters
hwmHigh 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.
lwmLow water mark. Determines how many bytes must be in the queue before supplier threads are allowed to enqueue additional data. By default, the hwm equals lwm, 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."
nsNotification strategy. Pointer to an object conforming to the ACE_Notification_Strategy interface. If set, the object's notify(void) method will be called each time data is added to this ACE_Message_Queue.
See also
ACE_Reactor_Notification_Strategy.
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::~ACE_Message_Queue ( void  )
virtual

Releases all resources from the message queue and marks it deactivated.

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

Member Function Documentation

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::activate ( void  )
virtual

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

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::activate_i ( void  )
protectedvirtual

Activate the queue.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::close ( void  )
virtual

Releases all resources from the message queue and marks it deactivated.

See also
flush().
Return values
Thenumber of messages released from the queue; -1 on error.

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::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.

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::deactivate_i ( int  pulse = 0)
protectedvirtual

Notifies all waiting threads that the queue has been deactivated so they can wakeup and continue other processing. No messages are removed from the queue.

Parameters
pulseIf 0, the queue's state is changed to DEACTIVATED and any other operations called until the queue is reactivated will immediately return -1 with errno == ESHUTDOWN. If not zero, only the waiting threads are notified and the queue's state changes to PULSED.
Returns
The state of the queue before the call.
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::deactivated ( void  )
virtual

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

Implements ACE_Message_Queue_Base.

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

This method is an alias for the dequeue_head() method.

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::dequeue_deadline ( ACE_Message_Block *&  dequeued,
ACE_Time_Value timeout = 0 
)
virtual

Dequeue the ACE_Message_Block with the earliest deadline time and return a pointer to the dequeued block.

Parameters
dequeuedReference to an ACE_Message_Block * that will be set to the address of the dequeued block.
timeoutThe absolute time the caller will wait until for a block to be dequeued.
Return values
>=0The number of ACE_Message_Blocks remaining in the queue.
-1On failure. errno holds the reason. Common errno values are:
  • EWOULDBLOCK: the timeout elapsed
  • ESHUTDOWN: the queue was deactivated or pulsed
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::dequeue_deadline_i ( ACE_Message_Block *&  first_item)
protectedvirtual

Dequeue and return the <ACE_Message_Block *> with the lowest deadline time.

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

Dequeue the ACE_Message_Block at the head of the queue and return a pointer to the dequeued block.

Parameters
first_itemReference to an ACE_Message_Block * that will be set to the address of the dequeued block.
timeoutThe absolute time the caller will wait until for a block to be dequeued.
Return values
>=0The number of ACE_Message_Blocks remaining in the queue.
-1On failure. errno holds the reason. Common errno values are:
  • EWOULDBLOCK: the timeout elapsed
  • ESHUTDOWN: the queue was deactivated or pulsed

Implements ACE_Message_Queue_Base.

Reimplemented in ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_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 queue.

Reimplemented in ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >.

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

Dequeue the ACE_Message_Block that has the lowest priority (preserves FIFO order for messages with the same priority) and return a pointer to the dequeued block.

Parameters
first_itemReference to an ACE_Message_Block * that will be set to the address of the dequeued block.
timeoutThe absolute time the caller will wait until for a block to be dequeued.
Return values
>=0The number of ACE_Message_Blocks remaining in the queue.
-1On failure. errno holds the reason. Common errno values are:
  • EWOULDBLOCK: the timeout elapsed
  • ESHUTDOWN: the queue was deactivated or pulsed
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::dequeue_prio_i ( ACE_Message_Block *&  dequeued)
protectedvirtual

Dequeue and return the <ACE_Message_Block *> with the lowest priority.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::dequeue_tail ( ACE_Message_Block *&  dequeued,
ACE_Time_Value timeout = 0 
)
virtual

Dequeue the ACE_Message_Block at the tail of the queue and return a pointer to the dequeued block.

Parameters
dequeuedReference to an ACE_Message_Block * that will be set to the address of the dequeued block.
timeoutThe absolute time the caller will wait until for a block to be dequeued.
Return values
>=0The number of ACE_Message_Blocks remaining in the queue.
-1On failure. errno holds the reason. Common errno values are:
  • EWOULDBLOCK: the timeout elapsed
  • ESHUTDOWN: the queue was deactivated or pulsed
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::dequeue_tail_i ( ACE_Message_Block *&  first_item)
protectedvirtual

Dequeue and return the <ACE_Message_Block *> at the tail of the queue.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual void ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::dump ( void  ) const
virtual

Dump the state of an object.

Implements ACE_Message_Queue_Base.

Reimplemented in ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::enqueue ( ACE_Message_Block new_item,
ACE_Time_Value timeout = 0 
)
virtual
Deprecated:
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.

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::enqueue_deadline ( ACE_Message_Block new_item,
ACE_Time_Value timeout = 0 
)
virtual

Enqueue an ACE_Message_Block into the queue in accordance with the block's deadline time. FIFO order is maintained when messages of the same deadline time are inserted consecutively.

Parameters
new_itemPointer to an ACE_Message_Block that will be added to the queue. The block's msg_deadline_time() method will be called to obtain the relative queueing position.
timeoutThe absolute time the caller will wait until for the block to be queued.
Return values
>0The number of ACE_Message_Blocks on the queue after adding the specified block.
-1On failure. errno holds the reason. Common errno values are:
  • EWOULDBLOCK: the timeout elapsed
  • ESHUTDOWN: the queue was deactivated or pulsed
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::enqueue_deadline_i ( ACE_Message_Block new_item)
protectedvirtual

Enqueue an <ACE_Message_Block *> in accordance with its deadline time.

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

Enqueue one or more ACE_Message_Block objects at the head of the queue. If the new_item next() pointer is non-zero, it is assumed to be the start of a series of ACE_Message_Block objects connected via their next() pointers. The series of blocks will be added to the queue in the same order they are passed in as.

Parameters
new_itemPointer to an ACE_Message_Block that will be added to the queue. If the block's next() pointer is non-zero, all blocks chained from the next() pointer are enqueued as well.
timeoutThe absolute time the caller will wait until for the block to be queued.
Return values
>0The number of ACE_Message_Blocks on the queue after adding the specified block(s).
-1On failure. errno holds the reason. Common errno values are:
  • EWOULDBLOCK: the timeout elapsed
  • ESHUTDOWN: the queue was deactivated or pulsed

Reimplemented in ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::enqueue_head_i ( ACE_Message_Block new_item)
protectedvirtual

Enqueue an <ACE_Message_Block *> at the head of the queue.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_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.

Reimplemented in ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::enqueue_prio ( ACE_Message_Block new_item,
ACE_Time_Value timeout = 0 
)
virtual

Enqueue an ACE_Message_Block into the queue in accordance with the ACE_Message_Block's priority (0 is lowest priority). FIFO order is maintained when messages of the same priority are inserted consecutively.

Parameters
new_itemPointer to an ACE_Message_Block that will be added to the queue. The block's msg_priority() method will be called to obtain the queueing priority.
timeoutThe absolute time the caller will wait until for the block to be queued.
Return values
>0The number of ACE_Message_Blocks on the queue after adding the specified block.
-1On failure. errno holds the reason. Common errno values are:
  • EWOULDBLOCK: the timeout elapsed
  • ESHUTDOWN: the queue was deactivated or pulsed
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::enqueue_tail ( ACE_Message_Block new_item,
ACE_Time_Value timeout = 0 
)
virtual

Enqueue one or more ACE_Message_Block objects at the tail of the queue. If the new_item next() pointer is non-zero, it is assumed to be the start of a series of ACE_Message_Block objects connected via their next() pointers. The series of blocks will be added to the queue in the same order they are passed in as.

Parameters
new_itemPointer to an ACE_Message_Block that will be added to the queue. If the block's next() pointer is non-zero, all blocks chained from the next() pointer are enqueued as well.
timeoutThe absolute time the caller will wait until for the block to be queued.
Return values
>0The number of ACE_Message_Blocks on the queue after adding the specified block(s).
-1On failure. errno holds the reason. Common errno values are:
  • EWOULDBLOCK: the timeout elapsed
  • ESHUTDOWN: the queue was deactivated or pulsed

Implements ACE_Message_Queue_Base.

Reimplemented in ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::enqueue_tail_i ( ACE_Message_Block new_item)
protectedvirtual

Enqueue an <ACE_Message_Block *> at the end of the queue.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::flush ( void  )
virtual

Releases all resources from the message queue but does not mark it deactivated. This method holds the queue lock during this operation.

See also
close().
Returns
The number of messages flushed; -1 on error.
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::flush_i ( void  )
virtual

Release all resources from the message queue but do not mark it as deactivated.

Precondition
The caller must be holding the queue lock before calling this method.
Returns
The number of messages flushed.
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Time_Value_T<TIME_POLICY> ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::gettimeofday ( void  ) const

Get the current time of day according to the queue's TIME_POLICY. Allows users to initialize timeout values using correct time policy.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual size_t ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::high_water_mark ( void  )
virtual

Get high watermark.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual void ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::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 , class TIME_POLICY = ACE_System_Time_Policy>
virtual bool ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::is_empty ( void  )
virtual

True if queue is empty, else false.

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual bool ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::is_empty_i ( void  )
protectedvirtual

True if queue is empty, else false.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual bool ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::is_full ( void  )
virtual

True if queue is full, else false.

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual bool ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::is_full_i ( void  )
protectedvirtual

True if queue is full, else false.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual ACE_SYNCH_MUTEX_T& ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::lock ( void  )
virtual

Returns a reference to the lock used by the ACE_Message_Queue.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual size_t ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::low_water_mark ( void  )
virtual

Get low watermark.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual void ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::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_Blocks.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual size_t ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::message_bytes ( void  )
virtual

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

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual void ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::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.

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual size_t ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::message_count ( void  )
virtual

Number of total messages on the queue.

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual size_t ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::message_length ( void  )
virtual

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

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual void ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::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.

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual ACE_Notification_Strategy* ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::notification_strategy ( void  )
virtual

Get the notification strategy for the <Message_Queue>

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual void ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::notification_strategy ( ACE_Notification_Strategy s)
virtual

Set the notification strategy for the <Message_Queue>

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::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 , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::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.

Parameters
hwmHigh 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.
lwmLow water mark. Determines how many bytes must be in the queue before supplier threads are allowed to enqueue additional data. By default, the hwm equals lwm, 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."
nsNotification strategy. Pointer to an object conforming to the ACE_Notification_Strategy interface. If set, the object's notify(void) method will be called each time data is added to this ACE_Message_Queue.
See also
ACE_Reactor_Notification_Strategy.
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
void ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::operator= ( const ACE_Message_Queue< _ACE_SYNCH > &  )
private

Sends the size of the queue whenever it changes.

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

Retrieve a pointer to the first ACE_Message_Block in the queue without removing it.

Note
Because the block whose pointer is returned is still on the queue, another thread may dequeue the referenced block at any time, including before the calling thread examines the peeked-at block. Be very careful with this method in multithreaded queueing situations.
Parameters
first_itemReference to an ACE_Message_Block * that will point to the first block on the queue. The block remains on the queue until this or another thread dequeues it.
timeoutThe absolute time the caller will wait until for a block to be queued.
Return values
>0The number of ACE_Message_Blocks on the queue.
-1On failure. errno holds the reason. Common errno values are:
  • EWOULDBLOCK: the timeout elapsed
  • ESHUTDOWN: the queue was deactivated or pulsed

Implements ACE_Message_Queue_Base.

Reimplemented in ACE_Dynamic_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::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.

Returns
The queue's state before this call.

Implements ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
void ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::set_time_policy ( TIME_POLICY const &  time_policy)

Allows applications to control how the timer queue gets the time of day.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::signal_dequeue_waiters ( void  )
protectedvirtual

Inform any threads waiting to dequeue that they can procede.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::signal_enqueue_waiters ( void  )
protectedvirtual

Inform any threads waiting to enqueue that they can procede.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::state ( void  )
virtual

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

Reimplemented from ACE_Message_Queue_Base.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::wait_not_empty_cond ( ACE_Time_Value timeout)
protectedvirtual

Wait for the queue to become non-empty.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
virtual int ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::wait_not_full_cond ( ACE_Time_Value timeout)
protectedvirtual

Wait for the queue to become non-full.

Friends And Related Function Documentation

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
friend class ACE_Message_Queue_Iterator< ACE_SYNCH_USE, TIME_POLICY >
friend
template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
friend class ACE_Message_Queue_Reverse_Iterator< ACE_SYNCH_USE, TIME_POLICY >
friend

Member Data Documentation

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_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_Condition_Attributes_T<TIME_POLICY> ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::cond_attr_
protected

Attributes to initialize conditions with.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
size_t ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::cur_bytes_
protected

Current number of bytes in the queue.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
size_t ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::cur_count_
protected

Current number of messages in the queue.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
size_t ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::cur_length_
protected

Current length of messages in the queue.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Message_Block* ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::head_
protected

Pointer to head of ACE_Message_Block list.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
size_t ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::high_water_mark_
protected

Greatest number of bytes before blocking.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_SYNCH_MUTEX_T ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::lock_
protected

Protect queue from concurrent access.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
size_t ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::low_water_mark_
protected

Lowest number before unblocking occurs.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_SYNCH_CONDITION_T ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::not_empty_cond_
protected

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

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_SYNCH_CONDITION_T ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::not_full_cond_
protected

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

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Notification_Strategy* ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::notification_strategy_
protected

The notification strategy used when a new message is enqueued.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
ACE_Message_Block* ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::tail_
protected

Pointer to tail of ACE_Message_Block list.

template<ACE_SYNCH_DECL , class TIME_POLICY = ACE_System_Time_Policy>
TIME_POLICY ACE_Message_Queue< ACE_SYNCH_DECL, TIME_POLICY >::time_policy_
protected

The policy to return the current time of day.


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