TransportQueueElement.inl

Go to the documentation of this file.
00001 /*
00002  *
00003  *
00004  * Distributed under the OpenDDS License.
00005  * See: http://www.opendds.org/license.html
00006  */
00007 
00008 #include "ace/Message_Block.h"
00009 #include "EntryExit.h"
00010 
00011 namespace OpenDDS {
00012 namespace DCPS {
00013 
00014 ACE_INLINE
00015 TransportQueueElement::TransportQueueElement(unsigned long initial_count)
00016   : sub_loan_count_(initial_count),
00017     dropped_(false),
00018     released_(false)
00019 {
00020   DBG_ENTRY_LVL("TransportQueueElement", "TransportQueueElement", 6);
00021 }
00022 
00023 ACE_INLINE
00024 bool
00025 TransportQueueElement::data_dropped(bool dropped_by_transport)
00026 {
00027   DBG_ENTRY_LVL("TransportQueueElement", "data_dropped", 6);
00028   this->dropped_ = true;
00029   return this->decision_made(dropped_by_transport);
00030 }
00031 
00032 ACE_INLINE
00033 bool
00034 TransportQueueElement::data_delivered()
00035 {
00036   DBG_ENTRY_LVL("TransportQueueElement", "data_delivered", 6);
00037   // Decision made depend on dropped_ flag. If any link drops
00038   // the sample even other links deliver successfully, the
00039   // data dropped by transport will called back to writer.
00040   return this->decision_made(this->dropped_);
00041 }
00042 
00043 ACE_INLINE
00044 bool
00045 TransportQueueElement::decision_made(bool dropped_by_transport)
00046 {
00047   DBG_ENTRY_LVL("TransportQueueElement", "decision_made", 6);
00048 
00049   const unsigned long new_count = --this->sub_loan_count_;
00050   if (new_count == 0) {
00051     // All interested subscriptions have been satisfied.
00052 
00053     // The queue elements are released to its cached allocator
00054     // in release_element() call.
00055     // It's not necessary to set the released_ flag to true
00056     // as this element will be released anyway and not be
00057     // accessible. Note it can not be set after release_element
00058     // call.
00059     // this->released_ = true;
00060     this->release_element(dropped_by_transport);
00061     return true;
00062   }
00063 
00064   // ciju: The sub_loan_count_ has been observed to drop below zero.
00065   // Since it isn't exactly a ref count and the object is created in
00066   // allocater memory (user space) we *probably* can disregard the
00067   // count for now. Ideally we would like to prevent the count from
00068   // falling below 0 and opening up this assert.
00069   // assert (new_count > 0);
00070   return false;
00071 }
00072 
00073 ACE_INLINE
00074 bool
00075 TransportQueueElement::was_dropped() const
00076 {
00077   return this->dropped_;
00078 }
00079 
00080 ACE_INLINE
00081 bool
00082 TransportQueueElement::released() const
00083 {
00084   return this->released_;
00085 }
00086 
00087 ACE_INLINE
00088 void
00089 TransportQueueElement::released(bool flag)
00090 {
00091   this->released_ = flag;
00092 }
00093 
00094 ACE_INLINE
00095 bool
00096 TransportQueueElement::MatchOnPubId::matches(
00097   const TransportQueueElement& candidate) const
00098 {
00099   return this->pub_id_ == candidate.publication_id()
00100     && this->pub_id_ != GUID_UNKNOWN;
00101 }
00102 
00103 ACE_INLINE
00104 bool
00105 TransportQueueElement::MatchOnDataPayload::matches(
00106   const TransportQueueElement& candidate) const
00107 {
00108   if (!candidate.msg_payload()) {
00109     return false;
00110   }
00111   return this->data_ == candidate.msg_payload()->rd_ptr();
00112 }
00113 
00114 }
00115 }

Generated on Fri Feb 12 20:05:28 2016 for OpenDDS by  doxygen 1.4.7