#include <Activation_Queue.h>
Collaboration diagram for ACE_Activation_Queue:

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_Request * | dequeue (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_Allocator * | allocator_ |
| Allocation strategy of the queue. More... | |
| ACE_Allocator * | data_block_allocator_ |
| Allocation strategy of the message blocks. More... | |
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 45 of file Activation_Queue.h.
|
||||||||||||||||
|
Constructor. Initializes a new activation queue.
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 } |
|
|
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 }
|
|
|
|
|
|
Dequeue the next available ACE_Method_Request.
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 }
|
|
|
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 }
|
|
||||||||||||
|
Enqueue the ACE_Method_Request in priority order.
The priority of the method request is obtained via the
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 }
|
|
|
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_.
|
|
|
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_.
|
|
|
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 }
|
|
|
|
|
|
Set the pointer to the underlying queue.
Definition at line 31 of file Activation_Queue.i. References queue_.
00032 {
00033 queue_ = q;
00034 }
|
|
|
Get a pointer to the underlying queue.
Definition at line 25 of file Activation_Queue.i. References queue_.
00026 {
00027 return queue_;
00028 }
|
|
|
Declare the dynamic allocation hooks.
Definition at line 135 of file Activation_Queue.h. |
|
|
Allocation strategy of the queue.
Definition at line 146 of file Activation_Queue.h. Referenced by ACE_Activation_Queue, and enqueue. |
|
|
Allocation strategy of the message blocks.
Definition at line 149 of file Activation_Queue.h. Referenced by enqueue. |
|
|
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. |
|
|
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. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002