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

ACE_Activation_Queue Class Reference

Reifies a method into a request. Subclasses typically represent necessary state and behavior. More...

#include <Activation_Queue.h>

Collaboration diagram for ACE_Activation_Queue:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Activation_Queue (ACE_Message_Queue< ACE_SYNCH > *new_queue=0, ACE_Allocator *alloc=0, ACE_Allocator *db_alloc=0)
 Constructor. More...

virtual ~ACE_Activation_Queue (void)
 Destructor. More...

ACE_Method_Requestdequeue (ACE_Time_Value *tv=0)
 Dequeue the next available ACE_Method_Request. More...

int enqueue (ACE_Method_Request *new_method_request, ACE_Time_Value *tv=0)
 Enqueue the ACE_Method_Request in priority order. More...

size_t method_count (void) const
 Get the current number of method objects in the queue. More...

int is_empty (void) const
 Returns 1 if the queue is empty, 0 otherwise. More...

int is_full (void) const
 Returns 1 if the queue is full, 0 otherwise. More...

void dump (void) const
 Dump the state of an request. More...

ACE_Message_Queue< ACE_SYNCH > * queue (void) const
 Get a pointer to the underlying queue. More...

void queue (ACE_Message_Queue< ACE_SYNCH > *q)
 Set the pointer to the underlying queue. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Attributes

ACE_Message_Queue< ACE_SYNCH > * queue_
 Stores the <Method_Requests>. More...

int delete_queue_
 Keeps track of whether we need to delete the queue. More...


Private Methods

void operator= (const ACE_Activation_Queue &)
 ACE_Activation_Queue (const ACE_Activation_Queue &)

Private Attributes

ACE_Allocatorallocator_
 Allocation strategy of the queue. More...

ACE_Allocatordata_block_allocator_
 Allocation strategy of the message blocks. More...


Detailed Description

Reifies a method into a request. Subclasses typically represent necessary state and behavior.

Maintains a priority-ordered queue of ACE_Method_Request objects. A scheduler class (often derived from ACE_Task) subsequently removes each method request and invokes its call() method.

This class is discussed in depth in the Active Object chapter of POSA2. In that book, it is referred to as an Activation List.

See also:
ACE_Method_Request

Definition at line 45 of file Activation_Queue.h.


Constructor & Destructor Documentation

ACE_Activation_Queue::ACE_Activation_Queue ACE_Message_Queue< ACE_SYNCH > *    new_queue = 0,
ACE_Allocator   alloc = 0,
ACE_Allocator   db_alloc = 0
 

Constructor.

Initializes a new activation queue.

Parameters:
new_queue  The activation queue uses an ACE_Message_Queue to queue and order the method requests. If this argument is 0, a new ACE_Message_Queue is created for this object's use and will be deleted when this object is destroyed. If a non-zero pointer is supplied, the passed object will be used and will not be deleted when this object is destroyed. If an ACE_Task is being created to act as the scheduler, for instance, its ACE_Message_Queue pointer can be passed to this object.
alloc  Optional, the allocator to use when allocating ACE_Message_Block instances that wrap the method requests queued to this activation queue. Defaults to ACE_Allocator::instance().
db_alloc  Optional, the allocator to use when allocating data blocks for the ACE_Message_Block instances that wrap the method requests queued to this activation queue. Defaults to ACE_Allocator::instance().

Definition at line 31 of file Activation_Queue.cpp.

References ACE_NEW, allocator_, delete_queue_, ACE_Allocator::instance, and queue_.

00034   : delete_queue_ (0)
00035   , allocator_(alloc)
00036   , data_block_allocator_(db_alloc)
00037 {
00038   if (this->allocator_ == 0)
00039     this->allocator_ = ACE_Allocator::instance ();
00040 
00041   if (new_queue)
00042     this->queue_ = new_queue;
00043   else
00044     {
00045       ACE_NEW (this->queue_,
00046                ACE_Message_Queue<ACE_SYNCH>);
00047       this->delete_queue_ = 1;
00048     }
00049 }

ACE_Activation_Queue::~ACE_Activation_Queue void    [virtual]
 

Destructor.

Definition at line 51 of file Activation_Queue.cpp.

References delete_queue_, and queue_.

00052 {
00053   if (this->delete_queue_ != 0)
00054     delete this->queue_;
00055 }

ACE_Activation_Queue::ACE_Activation_Queue const ACE_Activation_Queue &    [private]
 


Member Function Documentation

ACE_Method_Request * ACE_Activation_Queue::dequeue ACE_Time_Value   tv = 0
 

Dequeue the next available ACE_Method_Request.

Parameters:
tv  If 0, the method will block until a method request is available, else will wait until the absolute time specified in the referenced ACE_Time_Value. This method will return, earlier, however, if queue is closed, deactivated, or when a signal occurs.
Return values:
Pointer  to the dequeued ACE_Method_Request object.
0  an error occurs; errno contains further information. If the specified timeout elapses, errno will be EWOULDBLOCK.

Definition at line 58 of file Activation_Queue.cpp.

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

00059 {
00060   ACE_Message_Block *mb;
00061 
00062   // Dequeue the message.
00063   if (this->queue_->dequeue_head (mb, tv) != -1)
00064     {
00065       // Get the next <Method_Request>.
00066       ACE_Method_Request *mr =
00067         ACE_reinterpret_cast (ACE_Method_Request *,
00068                               mb->base ());
00069       // Delete the message block.
00070       mb->release ();
00071       return mr;
00072     }
00073   else
00074     return 0;
00075 }

void ACE_Activation_Queue::dump void    const
 

Dump the state of an request.

Definition at line 17 of file Activation_Queue.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_Message_Queue< ACE_SYNCH >::dump, LM_DEBUG, LM_INFO, and queue_.

00018 {
00019   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00020   ACE_DEBUG ((LM_DEBUG,
00021               ACE_LIB_TEXT ("delete_queue_ = %d\n"),
00022               this->delete_queue_));
00023   ACE_DEBUG ((LM_INFO, ACE_LIB_TEXT ("queue_: \n")));
00024   if (this->queue_)
00025     this->queue_->dump();
00026   else
00027     ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("(NULL)\n")));
00028   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00029 }

int ACE_Activation_Queue::enqueue ACE_Method_Request   new_method_request,
ACE_Time_Value   tv = 0
 

Enqueue the ACE_Method_Request in priority order.

The priority of the method request is obtained via the priority() method of the queued method request. Priority ordering is determined by the ACE_Message_Queue class; 0 is the lowest priority.

Parameters:
new_method_request  Pointer to the ACE_Method_Request object to queue. This object's priority() method is called to obtain the priority.
tv  If 0, the method will block until the method request can be queued, else will wait until the absolute time specified in the referenced ACE_Time_Value. This method will return, earlier, however, if queue is closed, deactivated, or when a signal occurs.
Return values:
0  on success.
-1  if an error occurs; errno contains further information. If the specified timeout elapses, errno will be EWOULDBLOCK.

Definition at line 78 of file Activation_Queue.cpp.

References ACE_DES_FREE, ACE_NEW_MALLOC_RETURN, allocator_, data_block_allocator_, ACE_Message_Queue< ACE_SYNCH >::enqueue_prio, ACE_Time_Value::max_time, ACE_Message_Block::MB_DATA, ACE_Method_Request::priority, queue_, and ACE_Time_Value::zero.

00080 {
00081   ACE_Message_Block *mb;
00082 
00083   // We pass sizeof (*mr) here so that flow control will work
00084   // correctly.  Since we also pass <mr> note that no unnecessary
00085   // memory is actually allocated -- just the size field is set.
00086   ACE_NEW_MALLOC_RETURN (mb,
00087                          ACE_static_cast(ACE_Message_Block *,
00088                                          this->allocator_->malloc (sizeof (ACE_Message_Block))),
00089                          ACE_Message_Block (sizeof (*mr),    // size
00090                                             ACE_Message_Block::MB_DATA, // type
00091                                             0,       // cont
00092                                             (char *) mr,    // data
00093                                             0,       // allocator
00094                                             0,       // locking strategy
00095                                             mr->priority (), // priority
00096                                             ACE_Time_Value::zero,     // execution time
00097                                             ACE_Time_Value::max_time, // absolute time of deadline
00098                                             this->data_block_allocator_,  // data_block allocator
00099                                             this->allocator_), // message_block allocator
00100                          -1);
00101 
00102   // Enqueue in priority order.
00103   int result = this->queue_->enqueue_prio (mb, tv);
00104 
00105   // Free ACE_Message_Block if enqueue_prio failed.
00106   if (result == -1)
00107       ACE_DES_FREE (mb, this->allocator_->free, ACE_Message_Block);
00108 
00109   return result;
00110 }

ACE_INLINE int ACE_Activation_Queue::is_empty void    const
 

Returns 1 if the queue is empty, 0 otherwise.

Definition at line 19 of file Activation_Queue.i.

References ACE_Message_Queue< ACE_SYNCH >::is_empty, and queue_.

00020 {
00021   return queue_->is_empty ();
00022 }

ACE_INLINE int ACE_Activation_Queue::is_full void    const
 

Returns 1 if the queue is full, 0 otherwise.

Definition at line 13 of file Activation_Queue.i.

References ACE_Message_Queue< ACE_SYNCH >::is_full, and queue_.

00014 {
00015   return queue_->is_full ();
00016 } 

ACE_INLINE size_t ACE_Activation_Queue::method_count void    const
 

Get the current number of method objects in the queue.

Definition at line 7 of file Activation_Queue.i.

References ACE_Message_Queue< ACE_SYNCH >::message_count, and queue_.

00008 {
00009   return queue_->message_count ();
00010 }

void ACE_Activation_Queue::operator= const ACE_Activation_Queue &    [private]
 

ACE_INLINE void ACE_Activation_Queue::queue ACE_Message_Queue< ACE_SYNCH > *    q
 

Set the pointer to the underlying queue.

Definition at line 31 of file Activation_Queue.i.

References queue_.

00032 {
00033   queue_ = q;
00034 }

ACE_INLINE ACE_Message_Queue< ACE_SYNCH > * ACE_Activation_Queue::queue void    const
 

Get a pointer to the underlying queue.

Definition at line 25 of file Activation_Queue.i.

References queue_.

00026 {
00027   return queue_;
00028 }


Member Data Documentation

ACE_Activation_Queue::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 135 of file Activation_Queue.h.

ACE_Allocator* ACE_Activation_Queue::allocator_ [private]
 

Allocation strategy of the queue.

Definition at line 146 of file Activation_Queue.h.

Referenced by ACE_Activation_Queue, and enqueue.

ACE_Allocator* ACE_Activation_Queue::data_block_allocator_ [private]
 

Allocation strategy of the message blocks.

Definition at line 149 of file Activation_Queue.h.

Referenced by enqueue.

int ACE_Activation_Queue::delete_queue_ [protected]
 

Keeps track of whether we need to delete the queue.

Definition at line 142 of file Activation_Queue.h.

Referenced by ACE_Activation_Queue, and ~ACE_Activation_Queue.

ACE_Message_Queue<ACE_SYNCH>* ACE_Activation_Queue::queue_ [protected]
 

Stores the <Method_Requests>.

Definition at line 139 of file Activation_Queue.h.

Referenced by ACE_Activation_Queue, dequeue, dump, enqueue, is_empty, is_full, method_count, queue, and ~ACE_Activation_Queue.


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