#include <Activation_Queue.h>
Collaboration diagram for ACE_Activation_Queue:
Public Member Functions | |
ACE_Activation_Queue (ACE_Message_Queue< ACE_SYNCH > *new_queue=0, ACE_Allocator *alloc=0, ACE_Allocator *db_alloc=0) | |
Constructor. | |
virtual | ~ACE_Activation_Queue (void) |
Destructor. | |
ACE_Method_Request * | dequeue (ACE_Time_Value *tv=0) |
Dequeue the next available ACE_Method_Request. | |
int | enqueue (ACE_Method_Request *new_method_request, ACE_Time_Value *tv=0) |
Enqueue the ACE_Method_Request in priority order. | |
size_t | method_count (void) const |
Get the current number of method objects in the queue. | |
int | is_empty (void) const |
Returns 1 if the queue is empty, 0 otherwise. | |
int | is_full (void) const |
Returns 1 if the queue is full, 0 otherwise. | |
void | dump (void) const |
Dump the state of an request. | |
ACE_Message_Queue< ACE_SYNCH > * | queue (void) const |
Get a pointer to the underlying queue. | |
void | queue (ACE_Message_Queue< ACE_SYNCH > *q) |
Set the pointer to the underlying queue. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Protected Attributes | |
ACE_Message_Queue< ACE_SYNCH > * | queue_ |
Stores the Method_Requests. | |
bool | delete_queue_ |
Keeps track of whether we need to delete the queue. | |
Private Member Functions | |
ACE_Activation_Queue (const ACE_Activation_Queue &) | |
void | operator= (const ACE_Activation_Queue &) |
Private Attributes | |
ACE_Allocator * | allocator_ |
Allocation strategy of the queue. | |
ACE_Allocator * | data_block_allocator_ |
Allocation strategy of the message blocks. |
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.
Definition at line 50 of file Activation_Queue.h.
|
Constructor. Initializes a new activation queue.
Definition at line 38 of file Activation_Queue.cpp. References ACE_NEW, allocator_, delete_queue_, ACE_Allocator::instance(), and queue_.
00041 : delete_queue_ (false) 00042 , allocator_(alloc) 00043 , data_block_allocator_(db_alloc) 00044 { 00045 if (this->allocator_ == 0) 00046 this->allocator_ = ACE_Allocator::instance (); 00047 00048 if (new_queue) 00049 this->queue_ = new_queue; 00050 else 00051 { 00052 ACE_NEW (this->queue_, 00053 ACE_Message_Queue<ACE_SYNCH>); 00054 this->delete_queue_ = true; 00055 } 00056 } |
|
Destructor.
Definition at line 79 of file Activation_Queue.cpp. References delete_queue_, and queue_.
00080 { 00081 if (this->delete_queue_) 00082 delete this->queue_; 00083 } |
|
|
|
Dequeue the next available ACE_Method_Request.
Definition at line 86 of file Activation_Queue.cpp. References ACE_Message_Block::base(), ACE_Message_Queue< ACE_SYNCH >::dequeue_head(), queue_, and ACE_Message_Block::release().
00087 { 00088 ACE_Message_Block *mb = 0; 00089 00090 // Dequeue the message. 00091 if (this->queue_->dequeue_head (mb, tv) != -1) 00092 { 00093 // Get the next <Method_Request>. 00094 ACE_Method_Request *mr = 00095 reinterpret_cast<ACE_Method_Request *> (mb->base ()); 00096 // Delete the message block. 00097 mb->release (); 00098 return mr; 00099 } 00100 else 00101 return 0; 00102 } |
|
Dump the state of an request.
Definition at line 19 of file Activation_Queue.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_TEXT, ACE_Message_Queue< ACE_SYNCH >::dump(), LM_DEBUG, LM_INFO, and queue_.
00020 { 00021 #if defined (ACE_HAS_DUMP) 00022 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); 00023 ACE_DEBUG ((LM_DEBUG, 00024 ACE_TEXT ("delete_queue_ = %d\n"), 00025 this->delete_queue_)); 00026 ACE_DEBUG ((LM_INFO, ACE_TEXT ("queue_: \n"))); 00027 if (this->queue_) 00028 this->queue_->dump(); 00029 else 00030 //FUZZ: disable check_for_NULL 00031 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(NULL)\n"))); 00032 //FUZZ: enable check_for_NULL 00033 00034 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); 00035 #endif /* ACE_HAS_DUMP */ 00036 } |
|
Enqueue the ACE_Method_Request in priority order.
The priority of the method request is obtained via the
Definition at line 105 of file Activation_Queue.cpp. References ACE_DES_FREE, ACE_Message_Block, ACE_NEW_MALLOC_RETURN, allocator_, data_block_allocator_, ACE_Message_Queue< ACE_SYNCH >::enqueue_prio(), and queue_.
00107 { 00108 ACE_Message_Block *mb = 0; 00109 00110 // We pass sizeof (*mr) here so that flow control will work 00111 // correctly. Since we also pass <mr> note that no unnecessary 00112 // memory is actually allocated -- just the size field is set. 00113 ACE_NEW_MALLOC_RETURN (mb, 00114 static_cast<ACE_Message_Block *> (this->allocator_->malloc (sizeof (ACE_Message_Block))), 00115 ACE_Message_Block (sizeof (*mr), // size 00116 ACE_Message_Block::MB_DATA, // type 00117 0, // cont 00118 (char *) mr, // data 00119 0, // allocator 00120 0, // locking strategy 00121 mr->priority (), // priority 00122 ACE_Time_Value::zero, // execution time 00123 ACE_Time_Value::max_time, // absolute time of deadline 00124 this->data_block_allocator_, // data_block allocator 00125 this->allocator_), // message_block allocator 00126 -1); 00127 00128 // Enqueue in priority order. 00129 int const result = this->queue_->enqueue_prio (mb, tv); 00130 00131 // Free ACE_Message_Block if enqueue_prio failed. 00132 if (result == -1) 00133 ACE_DES_FREE (mb, this->allocator_->free, ACE_Message_Block); 00134 00135 return result; 00136 } |
|
Returns 1 if the queue is empty, 0 otherwise.
Definition at line 20 of file Activation_Queue.inl. References ACE_Message_Queue< ACE_SYNCH >::is_empty(), and queue_.
|
|
Returns 1 if the queue is full, 0 otherwise.
Definition at line 14 of file Activation_Queue.inl. References ACE_Message_Queue< ACE_SYNCH >::is_full(), and queue_.
|
|
Get the current number of method objects in the queue.
Definition at line 8 of file Activation_Queue.inl. References ACE_Message_Queue< ACE_SYNCH >::message_count(), and queue_.
00009 { 00010 return queue_->message_count (); 00011 } |
|
|
|
Set the pointer to the underlying queue.
Definition at line 59 of file Activation_Queue.cpp. References delete_queue_, and queue_.
00060 { 00061 // Destroy the internal queue if one exist. 00062 if (this->delete_queue_) 00063 { 00064 // Destroy the current queue. 00065 delete this->queue_; 00066 00067 // Set the flag to false. NOTE that the delete_queue_ flag is a 00068 // flag used to only indicate whether or not if an internal 00069 // ACE_Message_Queue has been created, therefore, it will not 00070 // affect the user if the user decided to replace the queue with 00071 // their own queue no matter how many time they call on this 00072 // function. 00073 this->delete_queue_ = false; 00074 } 00075 00076 queue_ = q; 00077 } |
|
Get a pointer to the underlying queue.
Definition at line 26 of file Activation_Queue.inl. References queue_.
00027 { 00028 return queue_; 00029 } |
|
Declare the dynamic allocation hooks.
Definition at line 140 of file Activation_Queue.h. |
|
Allocation strategy of the queue.
Definition at line 159 of file Activation_Queue.h. Referenced by ACE_Activation_Queue(), and enqueue(). |
|
Allocation strategy of the message blocks.
Definition at line 162 of file Activation_Queue.h. Referenced by enqueue(). |
|
Keeps track of whether we need to delete the queue.
Definition at line 154 of file Activation_Queue.h. Referenced by ACE_Activation_Queue(), queue(), and ~ACE_Activation_Queue(). |
|
Stores the Method_Requests.
Definition at line 151 of file Activation_Queue.h. Referenced by ACE_Activation_Queue(), dequeue(), dump(), enqueue(), is_empty(), is_full(), method_count(), queue(), and ~ACE_Activation_Queue(). |