TransportImpl.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "DCPS/DdsDcps_pch.h"
00009 #include "TransportImpl.h"
00010 #include "DataLink.h"
00011 #include "TransportExceptions.h"
00012 #include "dds/DCPS/BuiltInTopicUtils.h"
00013 #include "dds/DCPS/DataWriterImpl.h"
00014 #include "dds/DCPS/DataReaderImpl.h"
00015 #include "dds/DCPS/PublisherImpl.h"
00016 #include "dds/DCPS/SubscriberImpl.h"
00017 #include "dds/DCPS/Util.h"
00018 #include "dds/DCPS/MonitorFactory.h"
00019 #include "dds/DCPS/Service_Participant.h"
00020 #include "tao/debug.h"
00021 #include "dds/DCPS/SafetyProfileStreams.h"
00022
00023 #if !defined (__ACE_INLINE__)
00024 #include "TransportImpl.inl"
00025 #endif
00026
00027 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00028
00029 namespace OpenDDS {
00030 namespace DCPS {
00031
00032 TransportImpl::TransportImpl(TransportInst& config)
00033 : config_(config)
00034 , monitor_(0)
00035 , last_link_(0)
00036 , is_shut_down_(false)
00037 {
00038 DBG_ENTRY_LVL("TransportImpl", "TransportImpl", 6);
00039 if (TheServiceParticipant->monitor_factory_) {
00040 monitor_ = TheServiceParticipant->monitor_factory_->create_transport_monitor(this);
00041 }
00042 }
00043
00044 TransportImpl::~TransportImpl()
00045 {
00046 DBG_ENTRY_LVL("TransportImpl", "~TransportImpl", 6);
00047 }
00048
00049 bool
00050 TransportImpl::is_shut_down() const
00051 {
00052 return is_shut_down_;
00053 }
00054
00055 void
00056 TransportImpl::shutdown()
00057 {
00058 DBG_ENTRY_LVL("TransportImpl", "shutdown", 6);
00059
00060 is_shut_down_ = true;
00061
00062
00063 this->dl_clean_task_.close(1);
00064
00065 if (!this->reactor_task_.is_nil()) {
00066 this->reactor_task_->stop();
00067 }
00068
00069
00070 this->shutdown_i();
00071 }
00072
00073
00074 bool
00075 TransportImpl::open()
00076 {
00077
00078
00079
00080 if (this->dl_clean_task_.open()) {
00081 ACE_ERROR_RETURN((LM_ERROR,
00082 "(%P|%t) ERROR: DL Cleanup task failed to open : %p\n",
00083 ACE_TEXT("open")), false);
00084 }
00085
00086
00087 if (this->monitor_) {
00088 this->monitor_->report();
00089 }
00090
00091 if (Transport_debug_level > 0) {
00092
00093 ACE_DEBUG((LM_DEBUG,
00094 ACE_TEXT("(%P|%t) TransportImpl::open()\n%C"),
00095 dump_to_str().c_str()));
00096 }
00097
00098
00099 return true;
00100 }
00101
00102 void
00103 TransportImpl::add_pending_connection(const TransportClient_rch& client, DataLink_rch link)
00104 {
00105 pending_connections_.insert( PendConnMap::value_type(client, link));
00106 }
00107
00108 void
00109 TransportImpl::create_reactor_task(bool useAsyncSend)
00110 {
00111 if (is_shut_down_ || this->reactor_task_.in()) {
00112 return;
00113 }
00114
00115 this->reactor_task_= make_rch<TransportReactorTask>(useAsyncSend);
00116 if (0 != this->reactor_task_->open(0)) {
00117 throw Transport::MiscProblem();
00118 }
00119 }
00120
00121
00122 void
00123 TransportImpl::unbind_link(DataLink*)
00124 {
00125
00126 DBG_ENTRY_LVL("TransportImpl", "unbind_link",6);
00127 }
00128
00129 bool
00130 TransportImpl::release_link_resources(DataLink* link)
00131 {
00132 DBG_ENTRY_LVL("TransportImpl", "release_link_resources",6);
00133
00134
00135 dl_clean_task_.add(rchandle_from(link));
00136
00137 return true;
00138 }
00139
00140 void
00141 TransportImpl::report()
00142 {
00143 if (this->monitor_) {
00144 this->monitor_->report();
00145 }
00146 }
00147
00148 void
00149 TransportImpl::dump()
00150 {
00151 ACE_DEBUG((LM_DEBUG,
00152 ACE_TEXT("(%P|%t) TransportImpl::dump() -\n%C"),
00153 dump_to_str().c_str()));
00154 }
00155
00156 OPENDDS_STRING
00157 TransportImpl::dump_to_str()
00158 {
00159 return config_.dump_to_str();
00160 }
00161
00162 }
00163 }
00164
00165 OPENDDS_END_VERSIONED_NAMESPACE_DECL