OpenDDS  Snapshot(2023/04/07-19:43)
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Static Private Member Functions | Friends | List of all members
OpenDDS::DCPS::SendStateDataSampleList Class Reference

#include <SendStateDataSampleList.h>

Collaboration diagram for OpenDDS::DCPS::SendStateDataSampleList:
Collaboration graph
[legend]

Public Types

typedef SendStateDataSampleListIterator iterator
 STL-style bidirectional iterator and const-iterator types. More...
 
typedef SendStateDataSampleListConstIterator const_iterator
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 

Public Member Functions

 SendStateDataSampleList ()
 Default constructor clears the list. More...
 
 ~SendStateDataSampleList ()
 
void reset ()
 Reset to initial state. More...
 
ssize_t size () const
 
DataSampleElementhead () const
 
DataSampleElementtail () const
 
void enqueue_head (const DataSampleElement *element)
 
void enqueue_tail (const DataSampleElement *element)
 
void enqueue_tail (SendStateDataSampleList list)
 
bool dequeue_head (DataSampleElement *&stale)
 
bool dequeue (const DataSampleElement *stale)
 
iterator begin ()
 Return iterator to beginning of list. More...
 
const_iterator begin () const
 
iterator end ()
 Return iterator to end of list. More...
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 

Static Public Member Functions

template<size_t N>
static const SendStateDataSampleListsend_list_containing_element (const DataSampleElement *element, SendStateDataSampleList *(&send_lists)[N])
 
static void remove (DataSampleElement *stale)
 

Protected Attributes

DataSampleElementhead_
 The first element of the list. More...
 
DataSampleElementtail_
 The last element of the list. More...
 
ssize_t size_
 Number of elements in the list. More...
 

Static Private Member Functions

static const SendStateDataSampleListsend_list_containing_element (const DataSampleElement *element, SendStateDataSampleList **begin, SendStateDataSampleList **end)
 

Friends

class ::DDS_TEST
 

Detailed Description

A list of DataSampleElement pointers to be queued by the order the samples are to be transmitted over the transport layer. Cache the number of elements in the list so that list traversal is not required to find this information. The Publisher may use this to maintain a list of samples to be sent with PRESENTATION.access_scope==GROUP by obtaining data from each DataWriter as it becomes available and concatenating the data in the order in which it was written. Manages DataSampleElement's previous_send_sample/next_send_sample pointers

Definition at line 153 of file SendStateDataSampleList.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 166 of file SendStateDataSampleList.h.

◆ const_reverse_iterator

Definition at line 169 of file SendStateDataSampleList.h.

◆ iterator

STL-style bidirectional iterator and const-iterator types.

Definition at line 165 of file SendStateDataSampleList.h.

◆ reverse_iterator

Definition at line 168 of file SendStateDataSampleList.h.

Constructor & Destructor Documentation

◆ SendStateDataSampleList()

ACE_INLINE OpenDDS::DCPS::SendStateDataSampleList::SendStateDataSampleList ( )

Default constructor clears the list.

Definition at line 18 of file SendStateDataSampleList.inl.

References ACE_INLINE.

19  : head_(0),
20  tail_(0),
21  size_(0)
22 {
23 }
DataSampleElement * tail_
The last element of the list.
ssize_t size_
Number of elements in the list.
DataSampleElement * head_
The first element of the list.

◆ ~SendStateDataSampleList()

OpenDDS::DCPS::SendStateDataSampleList::~SendStateDataSampleList ( )
inline

Definition at line 173 of file SendStateDataSampleList.h.

173 {}

Member Function Documentation

◆ begin() [1/2]

ACE_INLINE SendStateDataSampleList::iterator OpenDDS::DCPS::SendStateDataSampleList::begin ( void  )

Return iterator to beginning of list.

Definition at line 144 of file SendStateDataSampleList.inl.

References ACE_INLINE, head_, and tail_.

Referenced by OpenDDS::DCPS::DataWriterImpl::association_complete_i(), OpenDDS::DCPS::WriteDataContainer::get_unsent_data(), OpenDDS::DCPS::DataDurabilityCache::insert(), OpenDDS::DCPS::WriteDataContainer::reenqueue_all(), rend(), and OpenDDS::DCPS::DataWriterImpl::replay_durable_data_for().

145 {
146  return iterator(this->head_, this->tail_, this->head_);
147 }
DataSampleElement * tail_
The last element of the list.
SendStateDataSampleListIterator iterator
STL-style bidirectional iterator and const-iterator types.
DataSampleElement * head_
The first element of the list.

◆ begin() [2/2]

ACE_INLINE SendStateDataSampleList::const_iterator OpenDDS::DCPS::SendStateDataSampleList::begin ( void  ) const

Definition at line 158 of file SendStateDataSampleList.inl.

References ACE_INLINE, head_, and tail_.

159 {
160  return const_iterator(this->head_, this->tail_, this->head_);
161 }
DataSampleElement * tail_
The last element of the list.
SendStateDataSampleListConstIterator const_iterator
DataSampleElement * head_
The first element of the list.

◆ dequeue()

bool OpenDDS::DCPS::SendStateDataSampleList::dequeue ( const DataSampleElement stale)

Definition at line 47 of file SendStateDataSampleList.cpp.

References dequeue_head(), head_, OpenDDS::DCPS::DataSampleElement::next_send_sample_, OpenDDS::DCPS::DataSampleElement::previous_send_sample_, size_, and tail_.

Referenced by OpenDDS::DCPS::WriteDataContainer::data_delivered(), OpenDDS::DCPS::WriteDataContainer::data_dropped(), OpenDDS::DCPS::WriteDataContainer::remove_excess_durable(), OpenDDS::DCPS::WriteDataContainer::remove_oldest_sample(), and OpenDDS::DCPS::ReplayerImpl::write().

48 {
49  if (head_ == 0) {
50  return false;
51  }
52 
53  // Same as dequeue from head.
54  if (stale == head_) {
55  DataSampleElement* tmp = head_;
56  return dequeue_head(tmp);
57  }
58 
59  // Search from head_->next_send_sample_.
60  DataSampleElement* toRemove = 0;
61  for (DataSampleElement* item = head_->next_send_sample_;
62  item != 0 && toRemove == 0;
63  item = item->next_send_sample_) {
64  if (item == stale) {
65  toRemove = item;
66  }
67  }
68 
69  if (toRemove) {
70  --size_;
71  // Remove from the previous element.
72  toRemove->previous_send_sample_->next_send_sample_ = toRemove->next_send_sample_;
73 
74  // Remove from the next element.
75  if (toRemove->next_send_sample_ != 0) {
76  // Remove from the inside of the list.
77  toRemove->next_send_sample_->previous_send_sample_ = toRemove->previous_send_sample_;
78 
79  } else {
80  // Remove from the tail of the list.
81  tail_ = toRemove->previous_send_sample_;
82  }
83 
84  toRemove->next_send_sample_ = 0;
85  toRemove->previous_send_sample_ = 0;
86  }
87 
88  return toRemove != 0;
89 }
bool dequeue_head(DataSampleElement *&stale)
DataSampleElement * tail_
The last element of the list.
DataSampleElement * previous_send_sample_
DataSampleElement * next_send_sample_
Thread of data being unsent/sending/sent/released.
ssize_t size_
Number of elements in the list.
DataSampleElement * head_
The first element of the list.

◆ dequeue_head()

ACE_INLINE bool OpenDDS::DCPS::SendStateDataSampleList::dequeue_head ( DataSampleElement *&  stale)

Definition at line 101 of file SendStateDataSampleList.inl.

References ACE_INLINE, head_, OpenDDS::DCPS::DataSampleElement::next_send_sample_, OpenDDS::DCPS::DataSampleElement::previous_send_sample_, size_, and tail_.

Referenced by dequeue(), and OpenDDS::DCPS::WriteDataContainer::~WriteDataContainer().

102 {
103  //
104  // Remove the oldest sample from the instance list.
105  //
106  stale = head_;
107 
108  if (head_ == 0) {
109  return false;
110 
111  } else {
112  --size_;
113 
115 
116  if (head_ == 0) {
117  tail_ = 0;
118 
119  } else {
121  }
122 
123  stale->next_send_sample_ = 0;
124  stale->previous_send_sample_ = 0;
125 
126  return true;
127  }
128 }
DataSampleElement * tail_
The last element of the list.
DataSampleElement * previous_send_sample_
DataSampleElement * next_send_sample_
Thread of data being unsent/sending/sent/released.
ssize_t size_
Number of elements in the list.
DataSampleElement * head_
The first element of the list.

◆ end() [1/2]

ACE_INLINE SendStateDataSampleList::iterator OpenDDS::DCPS::SendStateDataSampleList::end ( void  )

Return iterator to end of list.

Definition at line 151 of file SendStateDataSampleList.inl.

References ACE_INLINE, head_, and tail_.

Referenced by OpenDDS::DCPS::DataWriterImpl::association_complete_i(), OpenDDS::DCPS::WriteDataContainer::get_unsent_data(), OpenDDS::DCPS::DataDurabilityCache::insert(), rbegin(), OpenDDS::DCPS::WriteDataContainer::reenqueue_all(), OpenDDS::DCPS::DataWriterImpl::replay_durable_data_for(), and send_list_containing_element().

152 {
153  return iterator(this->head_, this->tail_, 0);
154 }
DataSampleElement * tail_
The last element of the list.
SendStateDataSampleListIterator iterator
STL-style bidirectional iterator and const-iterator types.
DataSampleElement * head_
The first element of the list.

◆ end() [2/2]

ACE_INLINE SendStateDataSampleList::const_iterator OpenDDS::DCPS::SendStateDataSampleList::end ( void  ) const

Definition at line 165 of file SendStateDataSampleList.inl.

References ACE_INLINE, head_, and tail_.

166 {
167  return const_iterator(this->head_, this->tail_, 0);
168 }
DataSampleElement * tail_
The last element of the list.
SendStateDataSampleListConstIterator const_iterator
DataSampleElement * head_
The first element of the list.

◆ enqueue_head()

ACE_INLINE void OpenDDS::DCPS::SendStateDataSampleList::enqueue_head ( const DataSampleElement element)

Definition at line 55 of file SendStateDataSampleList.inl.

References ACE_INLINE, head_, OpenDDS::DCPS::DataSampleElement::next_send_sample_, OpenDDS::DCPS::DataSampleElement::previous_send_sample_, size_, and tail_.

Referenced by OpenDDS::DCPS::WriteDataContainer::copy_and_prepend().

56 {
57  ++size_;
58 
59  // const_cast here so that higher layers don't need to pass around so many
60  // non-const pointers to DataSampleElement. Ideally the design would be
61  // changed to accommodate const-correctness throughout.
62  DataSampleElement* mSample = const_cast<DataSampleElement*>(sample);
63 
64  if (head_ == 0) {
65  head_ = tail_ = mSample;
66  sample->next_send_sample_ = sample->previous_send_sample_ = 0;
67 
68  } else {
69  sample->next_send_sample_ = head_;
70  sample->previous_send_sample_ = 0;
71  head_->previous_send_sample_ = mSample;
72  head_ = mSample;
73  }
74 }
DataSampleElement * tail_
The last element of the list.
DataSampleElement * previous_send_sample_
DataSampleElement * next_send_sample_
Thread of data being unsent/sending/sent/released.
ssize_t size_
Number of elements in the list.
DataSampleElement * head_
The first element of the list.

◆ enqueue_tail() [1/2]

ACE_INLINE void OpenDDS::DCPS::SendStateDataSampleList::enqueue_tail ( const DataSampleElement element)

Definition at line 78 of file SendStateDataSampleList.inl.

References ACE_INLINE, head_, OpenDDS::DCPS::DataSampleElement::next_send_sample_, OpenDDS::DCPS::DataSampleElement::previous_send_sample_, size_, and tail_.

Referenced by OpenDDS::DCPS::DataWriterImpl::association_complete_i(), OpenDDS::DCPS::WriteDataContainer::data_delivered(), OpenDDS::DCPS::WriteDataContainer::data_dropped(), OpenDDS::DCPS::WriteDataContainer::enqueue(), OpenDDS::DCPS::WriteDataContainer::enqueue_control(), OpenDDS::DCPS::WriteDataContainer::get_unsent_data(), OpenDDS::DCPS::DataWriterImpl::replay_durable_data_for(), OpenDDS::RTPS::Sedp::Writer::send_sample_i(), OpenDDS::DCPS::ReplayerImpl::write(), and OpenDDS::DCPS::DataWriterImpl::write().

79 {
80  ++size_;
81 
82  // const_cast here so that higher layers don't need to pass around so many
83  // non-const pointers to DataSampleElement. Ideally the design would be
84  // changed to accommodate const-correctness throughout.
85  DataSampleElement* mSample = const_cast<DataSampleElement*>(sample);
86 
87  if (head_ == 0) {
88  head_ = tail_ = mSample;
89  sample->next_send_sample_ = sample->previous_send_sample_ = 0;
90 
91  } else {
92  sample->previous_send_sample_ = tail_;
93  sample->next_send_sample_ = 0;
94  tail_->next_send_sample_ = mSample;
95  tail_ = mSample;
96  }
97 }
DataSampleElement * tail_
The last element of the list.
DataSampleElement * previous_send_sample_
DataSampleElement * next_send_sample_
Thread of data being unsent/sending/sent/released.
ssize_t size_
Number of elements in the list.
DataSampleElement * head_
The first element of the list.

◆ enqueue_tail() [2/2]

void OpenDDS::DCPS::SendStateDataSampleList::enqueue_tail ( SendStateDataSampleList  list)

Definition at line 92 of file SendStateDataSampleList.cpp.

References head_, OpenDDS::DCPS::DataSampleElement::next_send_sample_, OpenDDS::DCPS::DataSampleElement::previous_send_sample_, size_, and tail_.

93 {
94  if (head_ == 0) {
95  head_ = list.head_;
96  tail_ = list.tail_;
97  size_ = list.size_;
98 
99  } else {
100  tail_->next_send_sample_ = list.head_;
101  list.head_->previous_send_sample_ = tail_;
102  tail_ = list.tail_;
103  size_ = size_ + list.size_;
104  }
105 }
DataSampleElement * tail_
The last element of the list.
DataSampleElement * previous_send_sample_
DataSampleElement * next_send_sample_
Thread of data being unsent/sending/sent/released.
ssize_t size_
Number of elements in the list.
DataSampleElement * head_
The first element of the list.

◆ head()

ACE_INLINE DataSampleElement * OpenDDS::DCPS::SendStateDataSampleList::head ( void  ) const

◆ rbegin() [1/2]

ACE_INLINE SendStateDataSampleList::reverse_iterator OpenDDS::DCPS::SendStateDataSampleList::rbegin ( void  )

Definition at line 172 of file SendStateDataSampleList.inl.

References ACE_INLINE, and end().

Referenced by OpenDDS::DCPS::WriteDataContainer::copy_and_prepend().

173 {
174  return reverse_iterator(end());
175 }
std::reverse_iterator< iterator > reverse_iterator
iterator end()
Return iterator to end of list.

◆ rbegin() [2/2]

ACE_INLINE SendStateDataSampleList::const_reverse_iterator OpenDDS::DCPS::SendStateDataSampleList::rbegin ( void  ) const

Definition at line 186 of file SendStateDataSampleList.inl.

References ACE_INLINE, and end().

187 {
188  return const_reverse_iterator(end());
189 }
std::reverse_iterator< const_iterator > const_reverse_iterator
iterator end()
Return iterator to end of list.

◆ remove()

ACE_INLINE void OpenDDS::DCPS::SendStateDataSampleList::remove ( DataSampleElement stale)
static

Remove from whichever list "stale" belongs to, without needing a reference to the SendStateDataSampleList object itself. That SendStateDataSampleList is no longer accurate and can't be used.

Definition at line 132 of file SendStateDataSampleList.inl.

References ACE_INLINE, OpenDDS::DCPS::DataSampleElement::next_send_sample_, and OpenDDS::DCPS::DataSampleElement::previous_send_sample_.

Referenced by OpenDDS::DCPS::WriteDataContainer::data_delivered(), and OpenDDS::DCPS::WriteDataContainer::data_dropped().

133 {
134  if (stale->previous_send_sample_) {
135  stale->previous_send_sample_->next_send_sample_ = stale->next_send_sample_;
136  }
137  if (stale->next_send_sample_) {
138  stale->next_send_sample_->previous_send_sample_ = stale->previous_send_sample_;
139  }
140 }

◆ rend() [1/2]

ACE_INLINE SendStateDataSampleList::reverse_iterator OpenDDS::DCPS::SendStateDataSampleList::rend ( void  )

Definition at line 179 of file SendStateDataSampleList.inl.

References ACE_INLINE, and begin().

Referenced by OpenDDS::DCPS::WriteDataContainer::copy_and_prepend().

180 {
181  return reverse_iterator(begin());
182 }
std::reverse_iterator< iterator > reverse_iterator
iterator begin()
Return iterator to beginning of list.

◆ rend() [2/2]

ACE_INLINE SendStateDataSampleList::const_reverse_iterator OpenDDS::DCPS::SendStateDataSampleList::rend ( void  ) const

Definition at line 193 of file SendStateDataSampleList.inl.

References begin(), and OPENDDS_END_VERSIONED_NAMESPACE_DECL.

194 {
195  return const_reverse_iterator(begin());
196 }
std::reverse_iterator< const_iterator > const_reverse_iterator
iterator begin()
Return iterator to beginning of list.

◆ reset()

ACE_INLINE void OpenDDS::DCPS::SendStateDataSampleList::reset ( void  )

Reset to initial state.

Definition at line 26 of file SendStateDataSampleList.inl.

References ACE_INLINE, head_, size_, and tail_.

Referenced by OpenDDS::DCPS::WriteDataContainer::get_resend_data(), OpenDDS::DCPS::WriteDataContainer::get_unsent_data(), and OpenDDS::DCPS::DataWriterImpl::send_suspended_data().

27 {
28  head_ = tail_ = 0;
29  size_ = 0;
30 }
DataSampleElement * tail_
The last element of the list.
ssize_t size_
Number of elements in the list.
DataSampleElement * head_
The first element of the list.

◆ send_list_containing_element() [1/2]

const SendStateDataSampleList * OpenDDS::DCPS::SendStateDataSampleList::send_list_containing_element ( const DataSampleElement element,
SendStateDataSampleList **  begin,
SendStateDataSampleList **  end 
)
staticprivate

Definition at line 27 of file SendStateDataSampleList.cpp.

References end(), head(), and OpenDDS::DCPS::DataSampleElement::previous_send_sample_.

Referenced by OpenDDS::DCPS::WriteDataContainer::data_delivered(), OpenDDS::DCPS::WriteDataContainer::data_dropped(), and OpenDDS::DCPS::WriteDataContainer::remove_oldest_sample().

30 {
31  const DataSampleElement* head = element;
32 
33  while (head->previous_send_sample_ != 0) {
34  head = head->previous_send_sample_;
35  }
36 
37  for (SendStateDataSampleList** it = begin; it != end; ++it) {
38  if ((*it)->head_ == head) {
39  return *it;
40  }
41  }
42  return 0;
43 }
DataSampleElement * previous_send_sample_
SendStateDataSampleList()
Default constructor clears the list.
iterator begin()
Return iterator to beginning of list.
iterator end()
Return iterator to end of list.

◆ send_list_containing_element() [2/2]

template<size_t N>
static const SendStateDataSampleList* OpenDDS::DCPS::SendStateDataSampleList::send_list_containing_element ( const DataSampleElement element,
SendStateDataSampleList *(&)  send_lists[N] 
)
inlinestatic

Returns a pointer to the SendStateDataSampleList containing a given DataSampleElement for use in the typical situation where the send state of a DataSampleElement is tracked by shifting it between distinct SendStateDataSampleLists, one for each state

Definition at line 181 of file SendStateDataSampleList.h.

183  {
184  return send_list_containing_element(element,
185  &send_lists[0], &send_lists[N]);
186  }
static const SendStateDataSampleList * send_list_containing_element(const DataSampleElement *element, SendStateDataSampleList **begin, SendStateDataSampleList **end)

◆ size()

ACE_INLINE ssize_t OpenDDS::DCPS::SendStateDataSampleList::size ( void  ) const

◆ tail()

ACE_INLINE DataSampleElement * OpenDDS::DCPS::SendStateDataSampleList::tail ( void  ) const

Definition at line 48 of file SendStateDataSampleList.inl.

References ACE_INLINE, and tail_.

Referenced by OpenDDS::DCPS::TransportClient::send_i().

49 {
50  return tail_;
51 }
DataSampleElement * tail_
The last element of the list.

Friends And Related Function Documentation

◆ ::DDS_TEST

friend class ::DDS_TEST
friend

Definition at line 155 of file SendStateDataSampleList.h.

Member Data Documentation

◆ head_

DataSampleElement* OpenDDS::DCPS::SendStateDataSampleList::head_
protected

The first element of the list.

Definition at line 225 of file SendStateDataSampleList.h.

Referenced by begin(), dequeue(), dequeue_head(), end(), enqueue_head(), enqueue_tail(), head(), and reset().

◆ size_

ssize_t OpenDDS::DCPS::SendStateDataSampleList::size_
protected

Number of elements in the list.

Definition at line 231 of file SendStateDataSampleList.h.

Referenced by dequeue(), dequeue_head(), enqueue_head(), enqueue_tail(), reset(), and size().

◆ tail_

DataSampleElement* OpenDDS::DCPS::SendStateDataSampleList::tail_
protected

The last element of the list.

Definition at line 228 of file SendStateDataSampleList.h.

Referenced by begin(), dequeue(), dequeue_head(), end(), enqueue_head(), enqueue_tail(), reset(), and tail().


The documentation for this class was generated from the following files: