summaryrefslogtreecommitdiff
path: root/TAO/tao/Incoming_Message_Queue.cpp
diff options
context:
space:
mode:
authorbala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-07-06 04:41:00 +0000
committerbala <bala@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2001-07-06 04:41:00 +0000
commitd8ad30bbf6dbe53647040d40d2e53fbdf8edf4b8 (patch)
tree3874c3e46e81a1a1c5a6c459720e1c17cab62da2 /TAO/tao/Incoming_Message_Queue.cpp
parent08c2939a52133c144b5f17b7f8556b5dc046c0b0 (diff)
downloadATCD-d8ad30bbf6dbe53647040d40d2e53fbdf8edf4b8.tar.gz
ChangeLogTag: Thu Jul 5 23:30:07 2001 Balachandran Natarajan <bala@cs.wustl.edu>
Diffstat (limited to 'TAO/tao/Incoming_Message_Queue.cpp')
-rw-r--r--TAO/tao/Incoming_Message_Queue.cpp151
1 files changed, 151 insertions, 0 deletions
diff --git a/TAO/tao/Incoming_Message_Queue.cpp b/TAO/tao/Incoming_Message_Queue.cpp
new file mode 100644
index 00000000000..17f8b31d6b9
--- /dev/null
+++ b/TAO/tao/Incoming_Message_Queue.cpp
@@ -0,0 +1,151 @@
+#include "Incoming_Message_Queue.h"
+#include "ORB_Core.h"
+#include "debug.h"
+
+
+#if !defined (__ACE_INLINE__)
+# include "Incoming_Message_Queue.inl"
+#endif /* __ACE_INLINE__ */
+
+ACE_RCSID (tao, Incoming_Message_Queue, "$Id$")
+
+
+TAO_Incoming_Message_Queue::TAO_Incoming_Message_Queue (TAO_ORB_Core *orb_core)
+ : queued_data_ (0),
+ size_ (0),
+ orb_core_ (orb_core)
+{
+}
+
+TAO_Incoming_Message_Queue::~TAO_Incoming_Message_Queue (void)
+{
+ // Delete the QD
+ if (this->size_)
+ {
+ TAO_Queued_Data *qd = this->dequeue_head ();
+ TAO_Queued_Data::release (qd);
+ }
+}
+
+size_t
+TAO_Incoming_Message_Queue::copy_tail (ACE_Message_Block &block)
+{
+ // The size of message that is copied
+ size_t n = 0;
+
+ if (this->size_ > 0)
+ {
+ // Check to see if the length of the incoming block is less than
+ // that of the <missing_data_> of the tail.
+ if ((CORBA::Long)block.length () <= this->queued_data_->missing_data_)
+ {
+ n = block.length ();
+ }
+ else
+ {
+ n = this->queued_data_->missing_data_;
+ }
+
+ // Do the copy
+ this->queued_data_->msg_block_->copy (block.rd_ptr (),
+ n);
+
+ // Decerement the missing data
+ this->queued_data_->missing_data_ -= n;
+ }
+
+ return n;
+}
+
+TAO_Queued_Data *
+TAO_Incoming_Message_Queue::dequeue_head (void)
+{
+ // Get the node on the head of the queue...
+ TAO_Queued_Data *tmp =
+ this->queued_data_->next_;
+
+ // Reset the head node..
+ this->queued_data_->next_ = tmp->next_;
+
+ // Decrease the size
+ --this->size_;
+
+ return tmp;
+}
+
+TAO_Queued_Data *
+TAO_Incoming_Message_Queue::dequeue_tail (void)
+{
+ // This is a bit painful stuff...
+ if (this->size_ == 0)
+ return 0;
+
+ // Get the node on the head of the queue...
+ TAO_Queued_Data *tmp =
+ this->queued_data_->next_;
+
+ while (tmp->next_ != this->queued_data_)
+ {
+ tmp = tmp->next_;
+ }
+
+ // Put the head in tmp.
+ tmp->next_ = this->queued_data_->next_;
+
+ TAO_Queued_Data *ret_qd = this->queued_data_;
+
+ this->queued_data_ = tmp;
+
+ // Decrease the size
+ --this->size_;
+
+ return ret_qd;
+}
+
+
+int
+TAO_Incoming_Message_Queue::enqueue_tail (TAO_Queued_Data *nd)
+{
+ if (this->size_ == 0)
+ {
+ this->queued_data_ = nd;
+ this->queued_data_->next_ = this->queued_data_;
+ }
+ else
+ {
+ nd->next_ = this->queued_data_->next_;
+ this->queued_data_->next_ = nd;
+ this->queued_data_ = nd;
+ }
+
+ ++ this->size_;
+ return 0;
+}
+
+
+/************************************************************************/
+// Methods for TAO_Queued_Data
+/************************************************************************/
+
+
+TAO_Queued_Data::TAO_Queued_Data (void)
+ : msg_block_ (0),
+ missing_data_ (0),
+ byte_order_ (0),
+ major_version_ (0),
+ minor_version_ (0),
+ msg_type_ (TAO_PLUGGABLE_MESSAGE_MESSAGERROR),
+ next_ (0)
+{
+}
+
+TAO_Queued_Data::TAO_Queued_Data (ACE_Message_Block *mb)
+ : msg_block_ (mb),
+ missing_data_ (0),
+ byte_order_ (0),
+ major_version_ (0),
+ minor_version_ (0),
+ msg_type_ (TAO_PLUGGABLE_MESSAGE_MESSAGERROR),
+ next_ (0)
+{
+}