1 #include "ace/Activation_Queue.h"
3 #if !defined (__ACE_INLINE__)
4 #include "ace/Activation_Queue.inl"
5 #endif /* __ACE_INLINE__ */
7 #include "ace/Log_Category.h"
8 #include "ace/Method_Request.h"
9 #include "ace/Malloc_Base.h"
10 #include "ace/Time_Value.h"
12 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
14 ACE_ALLOC_HOOK_DEFINE (ACE_Activation_Queue
)
17 ACE_Activation_Queue::dump () const
19 #if defined (ACE_HAS_DUMP)
20 ACELIB_DEBUG ((LM_DEBUG
, ACE_BEGIN_DUMP
, this));
21 ACELIB_DEBUG ((LM_DEBUG
,
22 ACE_TEXT ("delete_queue_ = %d\n"),
23 this->delete_queue_
));
24 ACELIB_DEBUG ((LM_INFO
, ACE_TEXT ("queue_:\n")));
28 //FUZZ: disable check_for_NULL
29 ACELIB_DEBUG ((LM_DEBUG
, ACE_TEXT ("(NULL)\n")));
30 //FUZZ: enable check_for_NULL
32 ACELIB_DEBUG ((LM_DEBUG
, ACE_END_DUMP
));
33 #endif /* ACE_HAS_DUMP */
36 ACE_Activation_Queue::ACE_Activation_Queue (ACE_Message_Queue
<ACE_SYNCH
> *new_queue
,
38 ACE_Allocator
*db_alloc
)
39 : delete_queue_ (false)
41 , data_block_allocator_(db_alloc
)
43 if (this->allocator_
== 0)
44 this->allocator_
= ACE_Allocator::instance ();
47 this->queue_
= new_queue
;
50 ACE_NEW (this->queue_
,
51 ACE_Message_Queue
<ACE_SYNCH
>);
52 this->delete_queue_
= true;
57 ACE_Activation_Queue::queue (ACE_Message_Queue
<ACE_SYNCH
> *q
)
59 // Destroy the internal queue if one exist.
60 if (this->delete_queue_
)
62 // Destroy the current queue.
65 // Set the flag to false. NOTE that the delete_queue_ flag is a
66 // flag used to only indicate whether or not if an internal
67 // ACE_Message_Queue has been created, therefore, it will not
68 // affect the user if the user decided to replace the queue with
69 // their own queue no matter how many time they call on this
71 this->delete_queue_
= false;
77 ACE_Activation_Queue::~ACE_Activation_Queue ()
79 if (this->delete_queue_
)
84 ACE_Activation_Queue::dequeue (ACE_Time_Value
*tv
)
86 ACE_Message_Block
*mb
= 0;
88 // Dequeue the message.
89 if (this->queue_
->dequeue_head (mb
, tv
) != -1)
91 // Get the next <Method_Request>.
92 ACE_Method_Request
*mr
=
93 reinterpret_cast<ACE_Method_Request
*> (mb
->base ());
94 // Delete the message block.
103 ACE_Activation_Queue::enqueue (ACE_Method_Request
*mr
,
106 ACE_Message_Block
*mb
= 0;
108 // We pass sizeof (*mr) here so that flow control will work
109 // correctly. Since we also pass <mr> note that no unnecessary
110 // memory is actually allocated -- just the size field is set.
111 ACE_NEW_MALLOC_RETURN (mb
,
112 static_cast<ACE_Message_Block
*> (this->allocator_
->malloc (sizeof (ACE_Message_Block
))),
113 ACE_Message_Block (sizeof (*mr
), // size
114 ACE_Message_Block::MB_DATA
, // type
118 0, // locking strategy
119 mr
->priority (), // priority
120 ACE_Time_Value::zero
, // execution time
121 ACE_Time_Value::max_time
, // absolute time of deadline
122 this->data_block_allocator_
, // data_block allocator
123 this->allocator_
), // message_block allocator
126 // Enqueue in priority order.
127 int const result
= this->queue_
->enqueue_prio (mb
, tv
);
129 // Free ACE_Message_Block if enqueue_prio failed.
131 ACE_DES_FREE (mb
, this->allocator_
->free
, ACE_Message_Block
);
136 ACE_END_VERSIONED_NAMESPACE_DECL