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:

Collaboration graph
[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_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...

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.

Definition at line 877 of file Message_Queue_T.h.


Member Enumeration Documentation

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
anonymous enum
 

Enumeration values:
DEFAULT_PRIORITY 

Definition at line 882 of file Message_Queue_T.h.

00883   {
00884     DEFAULT_PRIORITY = 0
00885   };


Constructor & Destructor Documentation

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

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."

Definition at line 52 of file Message_Queue_T.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, ACE_Message_Queue< ACE_SYNCH_USE >::open, and queue_.

00055 {
00056   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::ACE_Message_Queue_Ex");
00057 
00058   if (this->queue_.open (hwm, lwm, ns) == -1)
00059     ACE_ERROR ((LM_ERROR,
00060                 ACE_LIB_TEXT ("ACE_Message_Queue_Ex")));
00061 }

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.

Definition at line 64 of file Message_Queue_T.cpp.

References ACE_TRACE.

00065 {
00066   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::~ACE_Message_Queue_Ex");
00067 }


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.

Definition at line 297 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::activate, and queue_.

00298 {
00299   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::activate");
00300 
00301   return this->queue_.activate ();
00302 }

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.

Definition at line 82 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::close, and queue_.

00083 {
00084   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::close");
00085 
00086   return this->queue_.close ();
00087 }

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.

Definition at line 289 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::deactivate, and queue_.

00290 {
00291   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::deactivate");
00292 
00293   return this->queue_.deactivate ();
00294 }

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.

Definition at line 313 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::deactivated, and queue_.

00314 {
00315   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::deactivated");
00316 
00317   return this->queue_.deactivated ();
00318 }

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.

Definition at line 188 of file Message_Queue_T.i.

References ACE_TRACE, and dequeue_head.

00190 {
00191   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue");
00192 
00193   return this->dequeue_head (first_item, timeout);
00194 }

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_TYPE *> 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.

Definition at line 308 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Block::base, ACE_Message_Queue< ACE_SYNCH_USE >::dequeue_deadline, queue_, and ACE_Message_Block::release.

00310 {
00311   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_deadline");
00312 
00313   ACE_Message_Block *mb;
00314 
00315   int cur_count = this->queue_.dequeue_deadline (mb, timeout);
00316 
00317   // Dequeue the message.
00318   if (cur_count != -1)
00319     {
00320       dequeued = ACE_reinterpret_cast (ACE_MESSAGE_TYPE *, mb->base ());
00321       // Delete the message block.
00322       mb->release ();
00323       return cur_count;
00324     }
00325   else
00326     return -1;
00327 }

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_TYPE *> 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.

Definition at line 230 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Block::base, ACE_Message_Queue< ACE_SYNCH_USE >::dequeue_head, queue_, and ACE_Message_Block::release.

Referenced by dequeue.

00232 {
00233   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_head");
00234 
00235   ACE_Message_Block *mb;
00236 
00237   int cur_count = this->queue_.dequeue_head (mb, timeout);
00238 
00239   // Dequeue the message.
00240   if (cur_count != -1)
00241     {
00242       first_item = ACE_reinterpret_cast (ACE_MESSAGE_TYPE *, mb->base ());
00243       // Delete the message block.
00244       mb->release ();
00245       return cur_count;
00246     }
00247   else
00248     return -1;
00249 }

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_TYPE *> 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.

Definition at line 256 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Block::base, ACE_Message_Queue< ACE_SYNCH_USE >::dequeue_prio, queue_, and ACE_Message_Block::release.

00258 {
00259   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_prio");
00260 
00261   ACE_Message_Block *mb;
00262 
00263   int cur_count = this->queue_.dequeue_prio (mb, timeout);
00264 
00265   // Dequeue the message.
00266   if (cur_count != -1)
00267     {
00268       dequeued = ACE_reinterpret_cast (ACE_MESSAGE_TYPE *, mb->base ());
00269       // Delete the message block.
00270       mb->release ();
00271       return cur_count;
00272     }
00273   else
00274     return -1;
00275 }

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_TYPE *> 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.

Definition at line 282 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Block::base, ACE_Message_Queue< ACE_SYNCH_USE >::dequeue_tail, queue_, and ACE_Message_Block::release.

00284 {
00285   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dequeue_tail");
00286 
00287   ACE_Message_Block *mb;
00288 
00289   int cur_count = this->queue_.dequeue_tail (mb, timeout);
00290 
00291   // Dequeue the message.
00292   if (cur_count != -1)
00293     {
00294       dequeued = ACE_reinterpret_cast (ACE_MESSAGE_TYPE *, mb->base ());
00295       // Delete the message block.
00296       mb->release ();
00297       return cur_count;
00298     }
00299   else
00300     return -1;
00301 }

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.

Definition at line 28 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::dump, and queue_.

00029 {
00030   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::dump");
00031 
00032   this->queue_.dump ();
00033 }

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.

Definition at line 149 of file Message_Queue_T.cpp.

References ACE_TRACE, and enqueue_prio.

00151 {
00152   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_prio");
00153 
00154   return this->enqueue_prio (new_item, timeout);
00155 }

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_TYPE *> 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.

Definition at line 180 of file Message_Queue_T.cpp.

References ACE_NEW_RETURN, ACE_TRACE, DEFAULT_PRIORITY, ACE_Message_Queue< ACE_SYNCH_USE >::enqueue_deadline, queue_, and ACE_Message_Block::release.

00182 {
00183   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_deadline");
00184 
00185   ACE_Message_Block *mb;
00186 
00187   ACE_NEW_RETURN (mb,
00188                   ACE_Message_Block ((char *) new_item,
00189                                      sizeof (*new_item),
00190                                      ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY ),
00191                   -1);
00192 
00193   int result = this->queue_.enqueue_deadline (mb, timeout);
00194   if (result == -1)
00195     // Zap the message.
00196     mb->release ();
00197 
00198   return result;
00199 }

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_TYPE *> 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.

Definition at line 124 of file Message_Queue_T.cpp.

References ACE_NEW_RETURN, ACE_TRACE, DEFAULT_PRIORITY, ACE_Message_Queue< ACE_SYNCH_USE >::enqueue_head, queue_, and ACE_Message_Block::release.

00126 {
00127   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head");
00128 
00129   ACE_Message_Block *mb;
00130 
00131   ACE_NEW_RETURN (mb,
00132                   ACE_Message_Block ((char *) new_item,
00133                                      sizeof (*new_item),
00134                                      ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY),
00135                   -1);
00136 
00137   int result = this->queue_.enqueue_head (mb, timeout);
00138   if (result == -1)
00139     // Zap the message.
00140     mb->release ();
00141   return result;
00142 }

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_TYPE *> 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.

Definition at line 158 of file Message_Queue_T.cpp.

References ACE_NEW_RETURN, ACE_TRACE, DEFAULT_PRIORITY, ACE_Message_Queue< ACE_SYNCH_USE >::enqueue_prio, queue_, and ACE_Message_Block::release.

Referenced by enqueue.

00160 {
00161   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_prio");
00162 
00163   ACE_Message_Block *mb;
00164 
00165   ACE_NEW_RETURN (mb,
00166                   ACE_Message_Block ((char *) new_item,
00167                                      sizeof (*new_item),
00168                                      ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY),
00169                   -1);
00170 
00171   int result = this->queue_.enqueue_prio (mb, timeout);
00172   if (result == -1)
00173     // Zap the message.
00174     mb->release ();
00175 
00176   return result;
00177 }

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_TYPE *> 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.

Definition at line 205 of file Message_Queue_T.cpp.

References ACE_NEW_RETURN, ACE_TRACE, DEFAULT_PRIORITY, ACE_Message_Queue< ACE_SYNCH_USE >::enqueue_tail, queue_, and ACE_Message_Block::release.

00207 {
00208   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail");
00209 
00210   ACE_Message_Block *mb;
00211 
00212   ACE_NEW_RETURN (mb,
00213                   ACE_Message_Block ((char *) new_item,
00214                                      sizeof (*new_item),
00215                                      ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY),
00216                   -1);
00217 
00218   int result = this->queue_.enqueue_tail (mb, timeout);
00219   if (result == -1)
00220     // Zap the message.
00221     mb->release ();
00222   return result;
00223 }

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.

Definition at line 90 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::flush, and queue_.

00091 {
00092   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush");
00093 
00094   return this->queue_.flush ();
00095 }

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.

Definition at line 98 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::flush_i, and queue_.

00099 {
00100   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::flush_i");
00101 
00102   return this->queue_.flush_i ();
00103 }

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."

Definition at line 241 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::high_water_mark, and queue_.

00242 {
00243   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::high_water_mark");
00244 
00245   this->queue_.high_water_mark (hwm);
00246 }

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.

Definition at line 233 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::high_water_mark, and queue_.

00234 {
00235   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::high_water_mark");
00236 
00237   return this->queue_.high_water_mark ();
00238 }

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.

Definition at line 215 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::is_empty, and queue_.

00216 {
00217   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::is_empty");
00218 
00219   return this->queue_.is_empty ();
00220 }

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.

Definition at line 225 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::is_full, and queue_.

00226 {
00227   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::is_full");
00228 
00229   return this->queue_.is_full ();
00230 }

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>.

Definition at line 1205 of file Message_Queue_T.h.

References ACE_SYNCH_MUTEX_T, ACE_Message_Queue< ACE_SYNCH_USE >::lock, and queue_.

01206     {
01207       // The Sun Forte 6 (CC 5.1) compiler is only happy if this is in the
01208       // header file      (j.russell.noseworthy@objectsciences.com)
01209       return this->queue_.lock ();
01210     }

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_TYPE>s.

Definition at line 257 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::low_water_mark, and queue_.

00258 {
00259   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::low_water_mark");
00260 
00261   this->queue_.low_water_mark (lwm);
00262 }

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.

Definition at line 249 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::low_water_mark, and queue_.

00250 {
00251   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::low_water_mark");
00252 
00253   return this->queue_.low_water_mark ();
00254 }

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

Definition at line 36 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::message_bytes, and queue_.

00037 {
00038   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_bytes");
00039 
00040   this->queue_.message_bytes (new_value);
00041 }

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.

Definition at line 265 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::message_bytes, and queue_.

00266 {
00267   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_bytes");
00268 
00269   return this->queue_.message_bytes ();
00270 }

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.

Definition at line 281 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::message_count, and queue_.

00282 {
00283   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_count");
00284 
00285   return this->queue_.message_count ();
00286 }

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

Definition at line 44 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::message_length, and queue_.

00045 {
00046   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_length");
00047 
00048   this->queue_.message_length (new_value);
00049 }

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.

Definition at line 273 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::message_length, and queue_.

00274 {
00275   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::message_length");
00276 
00277   return this->queue_.message_length ();
00278 }

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>.

Definition at line 205 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::notification_strategy, and queue_.

00206 {
00207   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notification_strategy");
00208 
00209   this->queue_.notification_strategy (s);
00210 }

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>.

Definition at line 197 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::notification_strategy, and queue_.

00198 {
00199   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notification_strategy");
00200 
00201   return this->queue_.notification_strategy ();
00202 }

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.

Definition at line 330 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::notify, and queue_.

00331 {
00332   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::notify");
00333 
00334   return this->queue_.notify ();
00335 }

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   = 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."

Definition at line 70 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::open, and queue_.

00073 {
00074   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::open");
00075 
00076   return this->queue_.open (hwm, lwm, ns);
00077 }

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_TYPE> 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.

Definition at line 108 of file Message_Queue_T.cpp.

References ACE_TRACE, ACE_Message_Block::base, ACE_Message_Queue< ACE_SYNCH_USE >::peek_dequeue_head, and queue_.

00110 {
00111   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::peek_dequeue_head");
00112 
00113   ACE_Message_Block *mb;
00114 
00115   int cur_count = this->queue_.peek_dequeue_head (mb, timeout);
00116 
00117   if (cur_count != -1)
00118     first_item  = ACE_reinterpret_cast (ACE_MESSAGE_TYPE *, mb->base ());
00119 
00120   return cur_count;
00121 }

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.

Definition at line 305 of file Message_Queue_T.i.

References ACE_TRACE, ACE_Message_Queue< ACE_SYNCH_USE >::pulse, and queue_.

00306 {
00307   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::pulse");
00308 
00309   return this->queue_.pulse ();
00310 }

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.

Definition at line 321 of file Message_Queue_T.i.

References ACE_TRACE, queue_, and ACE_Message_Queue< ACE_SYNCH_USE >::state.

00322 {
00323   ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::state");
00324 
00325   return this->queue_.state ();
00326 }


Member Data Documentation

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >
ACE_Message_Queue_Ex::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 1216 of file Message_Queue_T.h.

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>.

Definition at line 1220 of file Message_Queue_T.h.

Referenced by ACE_Message_Queue_Ex, activate, close, deactivate, deactivated, dequeue_deadline, dequeue_head, dequeue_prio, dequeue_tail, dump, enqueue_deadline, enqueue_head, enqueue_prio, enqueue_tail, flush, flush_i, high_water_mark, is_empty, is_full, lock, low_water_mark, message_bytes, message_count, message_length, notification_strategy, notify, open, peek_dequeue_head, pulse, and state.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:50:36 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002