blob: 5622b3875719b19699434f3fe3ffabc7552ab667 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#include "tao/Incoming_Message_Queue.h"
#include "tao/Queued_Data.h"
#include "tao/debug.h"
#include "ace/Log_Msg.h"
#include "ace/Malloc_Base.h"
#if !defined (__ACE_INLINE__)
# include "tao/Incoming_Message_Queue.inl"
#endif /* __ACE_INLINE__ */
TAO_BEGIN_VERSIONED_NAMESPACE_DECL
TAO_Incoming_Message_Queue::~TAO_Incoming_Message_Queue ()
{
CORBA::ULong const sz = this->size_;
// Delete all the nodes left behind
for (CORBA::ULong i = 0;
i < sz;
++i)
{
TAO_Queued_Data *qd = this->dequeue_head ();
TAO_Queued_Data::release (qd);
}
}
TAO_Queued_Data *
TAO_Incoming_Message_Queue::dequeue_head ()
{
if (this->size_ == 0)
return nullptr;
// Get the node on the head of the queue...
TAO_Queued_Data * const head = this->last_added_->next ();
// Reset the head node..
this->last_added_->next (head->next ());
// Decrease the size and reset last_added_ if empty
if (--this->size_ == 0)
this->last_added_ = nullptr;
return head;
}
TAO_Queued_Data *
TAO_Incoming_Message_Queue::dequeue_tail ()
{
// This is a bit painful stuff...
if (this->size_ == 0)
return nullptr;
// Get the node on the head of the queue...
TAO_Queued_Data *head = this->last_added_->next ();
while (head->next () != this->last_added_)
{
head = head->next ();
}
// Put the head in tmp.
head->next (this->last_added_->next ());
TAO_Queued_Data *ret_qd = this->last_added_;
this->last_added_ = head;
// Decrease the size
if (--this->size_ == 0)
this->last_added_ = nullptr;
return ret_qd;
}
int
TAO_Incoming_Message_Queue::enqueue_tail (TAO_Queued_Data *nd)
{
if (this->size_ == 0)
{
this->last_added_ = nd;
this->last_added_->next (this->last_added_);
}
else
{
nd->next (this->last_added_->next ());
this->last_added_->next (nd);
this->last_added_ = nd;
}
++this->size_;
return 0;
}
TAO_END_VERSIONED_NAMESPACE_DECL
|