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

Generated on 10 Aug 2018 for OpenDDS by  doxygen 1.6.1