TransportSendStrategy.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 "ThreadSynch.h"
00009 
00010 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00011 
00012 ACE_INLINE
00013 OpenDDS::DCPS::TransportSendStrategy::SendMode
00014 OpenDDS::DCPS::TransportSendStrategy::mode() const
00015 {
00016   DBG_ENTRY_LVL("TransportSendStrategy","mode",6);
00017 
00018   return mode_;
00019 }
00020 
00021 ACE_INLINE
00022 OpenDDS::DCPS::ThreadSynch*
00023 OpenDDS::DCPS::TransportSendStrategy::synch() const
00024 {
00025   DBG_ENTRY_LVL("TransportSendStrategy","synch",6);
00026 
00027   return synch_.get();
00028 }
00029 
00030 ACE_INLINE void
00031 OpenDDS::DCPS::TransportSendStrategy::send_start()
00032 {
00033   DBG_ENTRY_LVL("TransportSendStrategy","send_start",6);
00034 
00035   GuardType guard(this->lock_);
00036 
00037   if (!this->link_released_)
00038     ++this->start_counter_;
00039 }
00040 
00041 ACE_INLINE void
00042 OpenDDS::DCPS::TransportSendStrategy::link_released(bool flag)
00043 {
00044   DBG_ENTRY_LVL("TransportSendStrategy","link_released",6);
00045 
00046   GuardType guard(this->lock_);
00047   this->link_released_ = flag;
00048 }
00049 
00050 ACE_INLINE void
00051 OpenDDS::DCPS::TransportSendStrategy::relink(bool)
00052 {
00053   DBG_ENTRY_LVL("TransportSendStrategy","relink",6);
00054   // The subsclass needs implement this function for re-establishing
00055   // the link upon send failure.
00056 }
00057 
00058 ACE_INLINE void
00059 OpenDDS::DCPS::TransportSendStrategy::suspend_send()
00060 {
00061   DBG_ENTRY_LVL("TransportSendStrategy","suspend_send",6);
00062   GuardType guard(this->lock_);
00063 
00064   if (this->mode_ != MODE_TERMINATED && this->mode_ != MODE_SUSPEND) {
00065     this->mode_before_suspend_ = this->mode_;
00066     this->mode_ = MODE_SUSPEND;
00067   }
00068 }
00069 
00070 ACE_INLINE void
00071 OpenDDS::DCPS::TransportSendStrategy::resume_send()
00072 {
00073   DBG_ENTRY_LVL("TransportSendStrategy","resume_send",6);
00074   GuardType guard(this->lock_);
00075 
00076   // If this send strategy is reused when the connection is reestablished, then
00077   // we need re-initialize the mode_ and mode_before_suspend_.
00078   if (this->mode_ == MODE_TERMINATED) {
00079     this->header_.length_ = 0;
00080     this->pkt_chain_ = 0;
00081     this->header_complete_ = false;
00082     this->start_counter_ = 0;
00083     this->mode_ = MODE_DIRECT;
00084     this->mode_before_suspend_ = MODE_NOT_SET;
00085     this->delayed_delivered_notification_queue_.clear();
00086 
00087   } else if (this->mode_ == MODE_SUSPEND) {
00088     this->mode_ = this->mode_before_suspend_;
00089     this->mode_before_suspend_ = MODE_NOT_SET;
00090     if (this->queue_.size() > 0) {
00091       this->mode_ = MODE_QUEUE;
00092       this->synch_->work_available();
00093     }
00094 
00095   } else {
00096     ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: TransportSendStrategy::resume_send  The suspend or terminate"
00097                " is not called previously.\n"));
00098   }
00099 }
00100 
00101 ACE_INLINE const char*
00102 OpenDDS::DCPS::TransportSendStrategy::mode_as_str(SendMode mode)
00103 {
00104   static const char* SendModeStr[] = { "MODE_NOT_SET",
00105                                        "MODE_DIRECT",
00106                                        "MODE_QUEUE",
00107                                        "MODE_SUSPEND",
00108                                        "MODE_TERMINATED",
00109                                        "UNKNOWN"
00110                                      };
00111 
00112   return SendModeStr [mode];
00113 }
00114 
00115 ACE_INLINE bool
00116 OpenDDS::DCPS::TransportSendStrategy::isDirectMode()
00117 {
00118   return this->mode_ == MODE_DIRECT;
00119 }
00120 
00121 ACE_INLINE ssize_t
00122 OpenDDS::DCPS::TransportSendStrategy::send_bytes(const iovec iov[],
00123                                                  int n,
00124                                                  int& /*bp*/)
00125 {
00126   return send_bytes_i(iov, n);
00127 }
00128 
00129 ACE_INLINE ACE_HANDLE
00130 OpenDDS::DCPS::TransportSendStrategy::get_handle()
00131 {
00132   return ACE_INVALID_HANDLE;
00133 }
00134 
00135 
00136 ACE_INLINE size_t
00137 OpenDDS::DCPS::TransportSendStrategy::max_message_size() const
00138 {
00139   return 0;
00140 }
00141 
00142 ACE_INLINE OpenDDS::DCPS::TransportQueueElement*
00143 OpenDDS::DCPS::TransportSendStrategy::current_packet_first_element() const
00144 {
00145   return this->elems_.peek();
00146 }
00147 
00148 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