00001 /* 00002 * 00003 * 00004 * Distributed under the OpenDDS License. 00005 * See: http://www.opendds.org/license.html 00006 */ 00007 00008 #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/ 00009 #include "WriterDataSampleList.h" 00010 #include "DataSampleElement.h" 00011 #include "Definitions.h" 00012 #include "PublicationInstance.h" 00013 00014 #include "dds/DCPS/transport/framework/TransportSendListener.h" 00015 00016 #if !defined (__ACE_INLINE__) 00017 #include "WriterDataSampleList.inl" 00018 #endif /* __ACE_INLINE__ */ 00019 00020 namespace OpenDDS { 00021 namespace DCPS { 00022 00023 bool 00024 WriterDataSampleList::dequeue(const DataSampleElement* stale) 00025 { 00026 if (head_ == 0) { 00027 return false; 00028 } 00029 00030 if (stale == head_) { 00031 DataSampleElement* head = head_; 00032 return dequeue_head(head); 00033 } 00034 00035 // Search from head_->next_writer_sample_. 00036 bool found = false; 00037 00038 for (DataSampleElement* item = head_->next_writer_sample_ ; 00039 item != 0 ; 00040 item = item->next_writer_sample_) { 00041 if (item == stale) { 00042 found = true; 00043 break; 00044 } 00045 } 00046 00047 if (found) { 00048 // Adjust list size. 00049 -- size_ ; 00050 00051 // 00052 // Remove from the previous element. 00053 // 00054 if (stale->previous_writer_sample_ != 0) { 00055 // Remove from inside of the list. 00056 stale->previous_writer_sample_->next_writer_sample_ = stale->next_writer_sample_ ; 00057 00058 } else { 00059 // Remove from the head of the list. 00060 head_ = stale->next_writer_sample_ ; 00061 00062 if (head_ != 0) { 00063 head_->previous_writer_sample_ = 0; 00064 } 00065 } 00066 00067 // 00068 // Remove from the next element. 00069 // 00070 if (stale->next_writer_sample_ != 0) { 00071 // Remove the inside of the list. 00072 stale->next_writer_sample_->previous_writer_sample_ = stale->previous_writer_sample_ ; 00073 00074 } else { 00075 // Remove from the tail of the list. 00076 tail_ = stale->previous_writer_sample_ ; 00077 } 00078 00079 stale->next_writer_sample_ = 0; 00080 stale->previous_writer_sample_ = 0; 00081 } 00082 00083 return found; 00084 } 00085 00086 00087 } // namespace DCPS 00088 } // namespace OpenDDS