summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbala <balanatarajan@users.noreply.github.com>2001-05-03 19:55:29 +0000
committerbala <balanatarajan@users.noreply.github.com>2001-05-03 19:55:29 +0000
commit7e06af98f78132705e9de2c89614707a1eac4a1f (patch)
tree590d46f399f50675742c66bc7120d9ecc9b2b79a
parenta7e39417a2f37ca95093bd1afc8e04fc28c52a72 (diff)
downloadATCD-7e06af98f78132705e9de2c89614707a1eac4a1f.tar.gz
ChangeLogTag: Thu May 3 14:52:33 2001 Balachandran Natarajan <bala@cs.wustl.edu>
-rw-r--r--ChangeLog9
-rw-r--r--ChangeLogs/ChangeLog-02a9
-rw-r--r--ChangeLogs/ChangeLog-03a9
-rw-r--r--ace/CDR_Stream.cpp48
-rw-r--r--ace/CDR_Stream.h12
5 files changed, 71 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 7234c943ec9..1a4228901de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Thu May 3 14:52:33 2001 Balachandran Natarajan <bala@cs.wustl.edu>
+
+ * ace/CDR_Stream.h (ACE_InputCDR):
+ * ace/CDR_Stream.cpp: Removed the method steal_data () as it did
+ not serve the purpose. Added a new method exchange_data_blocks
+ (). This method exchanges data_blocks between two CDR
+ streams. The write and read pointers are also exchanged. This
+ method performs no allocation and no releases and is lock free.
+
Thu May 3 06:58:29 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
* ace/Acceptor.{h,cpp},
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index 7234c943ec9..1a4228901de 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,12 @@
+Thu May 3 14:52:33 2001 Balachandran Natarajan <bala@cs.wustl.edu>
+
+ * ace/CDR_Stream.h (ACE_InputCDR):
+ * ace/CDR_Stream.cpp: Removed the method steal_data () as it did
+ not serve the purpose. Added a new method exchange_data_blocks
+ (). This method exchanges data_blocks between two CDR
+ streams. The write and read pointers are also exchanged. This
+ method performs no allocation and no releases and is lock free.
+
Thu May 3 06:58:29 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
* ace/Acceptor.{h,cpp},
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index 7234c943ec9..1a4228901de 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,12 @@
+Thu May 3 14:52:33 2001 Balachandran Natarajan <bala@cs.wustl.edu>
+
+ * ace/CDR_Stream.h (ACE_InputCDR):
+ * ace/CDR_Stream.cpp: Removed the method steal_data () as it did
+ not serve the purpose. Added a new method exchange_data_blocks
+ (). This method exchanges data_blocks between two CDR
+ streams. The write and read pointers are also exchanged. This
+ method performs no allocation and no releases and is lock free.
+
Thu May 3 06:58:29 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
* ace/Acceptor.{h,cpp},
diff --git a/ace/CDR_Stream.cpp b/ace/CDR_Stream.cpp
index 0f64ff0d66d..079ffb3d5cc 100644
--- a/ace/CDR_Stream.cpp
+++ b/ace/CDR_Stream.cpp
@@ -1014,23 +1014,55 @@ ACE_InputCDR::reset (const ACE_Message_Block* data,
void
ACE_InputCDR::steal_from (ACE_InputCDR &cdr)
{
-#if 0
this->do_byte_swap_ = cdr.do_byte_swap_;
this->start_.data_block (cdr.start_.data_block ()->duplicate ());
this->start_.rd_ptr (cdr.start_.rd_ptr ());
this->start_.wr_ptr (cdr.start_.wr_ptr ());
-#endif
- this->steal_data (cdr);
cdr.reset_contents ();
}
void
-ACE_InputCDR::steal_data (ACE_InputCDR &cdr)
+ACE_InputCDR::exchange_data_blocks (ACE_InputCDR &cdr)
{
- this->do_byte_swap_ = cdr.do_byte_swap_;
- this->start_.data_block (cdr.start_.data_block ()->duplicate ());
- this->start_.rd_ptr (cdr.start_.rd_ptr ());
- this->start_.wr_ptr (cdr.start_.wr_ptr ());
+ // Exchange byte orders
+ int byte_order = cdr.do_byte_swap_;
+ cdr.do_byte_swap_ = this->do_byte_swap_;
+ this->do_byte_swap_ = byte_order;
+
+ // Get the destination read and write pointers
+ size_t drd_pos =
+ cdr.start_.rd_ptr () - cdr.start_.base ();
+ size_t dwr_pos =
+ cdr.start_.wr_ptr () - cdr.start_.base ();
+
+ // Get the source read & write pointers
+ size_t srd_pos =
+ this->start_.rd_ptr () - this->start_.base ();
+ size_t swr_pos =
+ this->start_.wr_ptr () - this->start_.base ();
+
+ // Exchange data_blocks. Dont release any of the data blocks.
+ ACE_Data_Block *dnb =
+ this->start_.replace_data_block (cdr.start_.data_block ());
+ cdr.start_.replace_data_block (dnb);
+
+
+ // Reset the <cdr> pointers to zero before it is set again.
+ cdr.start_.reset ();
+ this->start_.reset ();
+
+ // Set the read and write pointers.
+ if (cdr.start_.size () >= srd_pos)
+ cdr.start_.rd_ptr (srd_pos);
+
+ if (cdr.start_.size () >= swr_pos)
+ cdr.start_.wr_ptr (swr_pos);
+
+ if (this->start_.size () >= drd_pos)
+ this->start_.rd_ptr (drd_pos);
+
+ if (this->start_.size () >= dwr_pos)
+ this->start_.wr_ptr (dwr_pos);
}
diff --git a/ace/CDR_Stream.h b/ace/CDR_Stream.h
index f2dea99ee00..e249df4e910 100644
--- a/ace/CDR_Stream.h
+++ b/ace/CDR_Stream.h
@@ -672,14 +672,10 @@ public:
/// stream.
void steal_from (ACE_InputCDR &cdr);
- /// Steal the contents of <cdr> in to this stream and leave the
- /// <cdr> untouched.
- /// NOTE: This is a slight modification of the steal_from ()
- /// method. It doesn't invoke reset_contents () after stealing the
- /// contents and can be used where new data blocks for the <cdr> are
- /// not needed.
- void steal_data (ACE_InputCDR &cdr);
-
+ /// Exchange data blocks with the caller of this method. The read
+ /// and write pointers are also exchanged.
+ /// Note: We now do only with the start_ message block.
+ void exchange_data_blocks (ACE_InputCDR &cdr);
/// Re-initialize the CDR stream, forgetting about the old contents
/// of the stream and allocating a new buffer (from the allocators).