ACE_Message_Queue_Ex_N< ACE_MESSAGE_TYPE, ACE_SYNCH_DECL > Class Template Reference

A threaded message queueing facility, modeled after the queueing facilities in System V STREAMs which can enqueue multiple messages in one call. More...

#include <Message_Queue_T.h>

Inheritance diagram for ACE_Message_Queue_Ex_N< ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Message_Queue_Ex_N< ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ACE_Message_Queue_Ex_N (size_t high_water_mark=ACE_Message_Queue_Base::DEFAULT_HWM, size_t low_water_mark=ACE_Message_Queue_Base::DEFAULT_LWM, ACE_Notification_Strategy *ns=0)
virtual ~ACE_Message_Queue_Ex_N (void)
 Close down the message queue and release all resources.
virtual int enqueue_head (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *tv=0)
virtual int enqueue_tail (ACE_MESSAGE_TYPE *new_item, ACE_Time_Value *tv=0)

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Protected Member Functions

ACE_Message_Blockwrap_with_mbs_i (ACE_MESSAGE_TYPE *new_item)

Detailed Description

template<class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL>
class ACE_Message_Queue_Ex_N< ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >

A threaded message queueing facility, modeled after the queueing facilities in System V STREAMs which can enqueue multiple messages in one call.

As ACE_Message_Queue_Ex, ACE_Message_Queue_Ex_N 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.

The ACE_MESSAGE_TYPE messages that are sent to this queue can be chained. Messages are expected to have a next method that returns the next message in the chain; ACE_Message_Queue_Ex_N uses this method to run through all the incoming messages and enqueue them in one call.

Definition at line 1470 of file Message_Queue_T.h.


Constructor & Destructor Documentation

template<class ACE_MESSAGE_TYPE , ACE_SYNCH_DECL >
ACE_Message_Queue_Ex_N< ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >::ACE_Message_Queue_Ex_N ( size_t  high_water_mark = ACE_Message_Queue_Base::DEFAULT_HWM,
size_t  low_water_mark = ACE_Message_Queue_Base::DEFAULT_LWM,
ACE_Notification_Strategy ns = 0 
) [inline]

Initialize an ACE_Message_Queue_Ex_N. 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 messages. 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 425 of file Message_Queue_T.cpp.

00427                                  :
00428     ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE> (high_water_mark,
00429                                                            low_water_mark,
00430                                                            ns)
00431 {
00432   ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::ACE_Message_Queue_Ex_N");
00433 }

template<class ACE_MESSAGE_TYPE , ACE_SYNCH_DECL >
ACE_Message_Queue_Ex_N< ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >::~ACE_Message_Queue_Ex_N ( void   )  [inline, virtual]

Close down the message queue and release all resources.

Definition at line 436 of file Message_Queue_T.cpp.

00437 {
00438   ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::~ACE_Message_Queue_Ex_N");
00439 }


Member Function Documentation

template<class ACE_MESSAGE_TYPE , ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex_N< ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >::enqueue_head ( ACE_MESSAGE_TYPE *  new_item,
ACE_Time_Value tv = 0 
) [inline, virtual]

Enqueue one or more ACE_MESSAGE_TYPE 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_TYPE 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_item Pointer to an ACE_MESSAGE_TYPE 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.
tv The absolute time the caller will wait until for the block to be queued.
Return values:
>0 The number of ACE_MESSAGE_TYPE objects on the queue after adding the specified block(s).
-1 On failure. errno holds the reason. Common errno values are:

  • EWOULDBLOCK: the timeout elapsed
  • ESHUTDOWN: the queue was deactivated or pulsed

Reimplemented from ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, ACE_SYNCH_USE >.

Definition at line 443 of file Message_Queue_T.cpp.

00445 {
00446   ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_head");
00447 
00448   // Create a chained ACE_Message_Blocks wrappers around the 'chained'
00449   // ACE_MESSAGE_TYPES.
00450   ACE_Message_Block *mb = this->wrap_with_mbs_i (new_item);
00451   if (0 == mb)
00452     {
00453       return -1;
00454     }
00455 
00456   int result = this->queue_.enqueue_head (mb, timeout);
00457   if (-1 == result)
00458     {
00459       // Zap the messages.
00460       mb->release ();
00461     }
00462   return result;
00463 }

template<class ACE_MESSAGE_TYPE , ACE_SYNCH_DECL >
int ACE_Message_Queue_Ex_N< ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >::enqueue_tail ( ACE_MESSAGE_TYPE *  new_item,
ACE_Time_Value tv = 0 
) [inline, virtual]

Enqueue one or more ACE_MESSAGE_TYPE 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_TYPE 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_item Pointer to an ACE_MESSAGE_TYPE 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.
tv The absolute time the caller will wait until for the block to be queued.
Return values:
>0 The number of ACE_MESSAGE_TYPE objects on the queue after adding the specified block(s).
-1 On failure. errno holds the reason. Common errno values are:

  • EWOULDBLOCK: the timeout elapsed
  • ESHUTDOWN: the queue was deactivated or pulsed

Reimplemented from ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, ACE_SYNCH_USE >.

Definition at line 467 of file Message_Queue_T.cpp.

00469 {
00470   ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::enqueue_tail");
00471 
00472   // Create a chained ACE_Message_Blocks wrappers around the 'chained'
00473   // ACE_MESSAGE_TYPES.
00474   ACE_Message_Block *mb = this->wrap_with_mbs_i (new_item);
00475   if (0 == mb)
00476     {
00477       return -1;
00478     }
00479 
00480   int result = this->queue_.enqueue_tail (mb, timeout);
00481   if (-1 == result)
00482     {
00483       // Zap the message.
00484       mb->release ();
00485     }
00486   return result;
00487 }

template<class ACE_MESSAGE_TYPE , ACE_SYNCH_DECL >
ACE_Message_Block * ACE_Message_Queue_Ex_N< ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >::wrap_with_mbs_i ( ACE_MESSAGE_TYPE *  new_item  )  [inline, protected]

An helper method that wraps the incoming chain messages with ACE_Message_Blocks.

Definition at line 491 of file Message_Queue_T.cpp.

00492 {
00493   ACE_TRACE ("ACE_Message_Queue_Ex_N<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::wrap_with_mbs_i");
00494 
00495   // We need to keep a reference to the head of the chain
00496   ACE_Message_Block *mb_head = 0;
00497 
00498   ACE_NEW_RETURN (mb_head,
00499                   ACE_Message_Block ((char *) new_item,
00500                                      sizeof (*new_item),
00501                                      ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY),
00502                   0);
00503 
00504   // mb_tail will point to the last ACE_Message_Block
00505   ACE_Message_Block *mb_tail = mb_head;
00506 
00507   // Run through rest of the messages and wrap them
00508   for (ACE_MESSAGE_TYPE *pobj = new_item->next (); pobj; pobj = pobj->next ())
00509     {
00510       ACE_Message_Block *mb_temp = 0;
00511       ACE_NEW_NORETURN (mb_temp,
00512                         ACE_Message_Block ((char *) pobj,
00513                                            sizeof (*pobj),
00514                                            ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::DEFAULT_PRIORITY));
00515       if (mb_temp == 0)
00516         {
00517           mb_head->release ();
00518           mb_head = 0;
00519           break;
00520         }
00521 
00522       mb_tail->next (mb_temp);
00523       mb_tail = mb_temp;
00524     }
00525 
00526   return mb_head;
00527 }


Member Data Documentation

template<class ACE_MESSAGE_TYPE , ACE_SYNCH_DECL >
ACE_Message_Queue_Ex_N< ACE_MESSAGE_TYPE, ACE_SYNCH_DECL >::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Reimplemented from ACE_Message_Queue_Ex< ACE_MESSAGE_TYPE, ACE_SYNCH_USE >.

Definition at line 1541 of file Message_Queue_T.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Fri Nov 6 23:24:31 2009 for ACE by  doxygen 1.6.1