Line data Source code
1 : /* 2 : * 3 : * 4 : * Distributed under the OpenDDS License. 5 : * See: http://www.opendds.org/license.html 6 : */ 7 : 8 : #include "DCPS/DdsDcps_pch.h" //Only the _pch include should start with DCPS/ 9 : #include "DataLinkSet.h" 10 : #include "DataLinkSet_rch.h" 11 : 12 : #include "dds/DCPS/GuidConverter.h" 13 : #include "dds/DCPS/Util.h" 14 : #include "TransportImpl.h" 15 : #include "TransportSendListener.h" 16 : 17 : #include "EntryExit.h" 18 : 19 : #if !defined (__ACE_INLINE__) 20 : #include "DataLinkSet.inl" 21 : #endif /* __ACE_INLINE__ */ 22 : 23 : //TBD: The number of chunks in send control cached allocator and map 24 : // entry allocator are hard coded for now. These values will be 25 : // configured when we implement the dds configurations. 26 : 27 : /// The number of chuncks in send control cached allocator per pub/sub. 28 : #define NUM_SEND_CONTROL_ELEMENT_CHUNKS 20 29 : 30 3 : OpenDDS::DCPS::DataLinkSet::DataLinkSet() 31 3 : : send_response_listener_("DataLinkSet") 32 : { 33 : DBG_ENTRY_LVL("DataLinkSet","DataLinkSet",6); 34 3 : } 35 : 36 3 : OpenDDS::DCPS::DataLinkSet::~DataLinkSet() 37 : { 38 : DBG_ENTRY_LVL("DataLinkSet","~DataLinkSet",6); 39 3 : } 40 : 41 : int 42 0 : OpenDDS::DCPS::DataLinkSet::insert_link(const DataLink_rch& link) 43 : { 44 : DBG_ENTRY_LVL("DataLinkSet","insert_link",6); 45 0 : GuardType guard(this->lock_); 46 0 : return OpenDDS::DCPS::bind(map_, link->id(), link); 47 0 : } 48 : 49 : void 50 0 : OpenDDS::DCPS::DataLinkSet::remove_link(const DataLink_rch& link) 51 : { 52 : DBG_ENTRY_LVL("DataLinkSet", "remove_link", 6); 53 0 : GuardType guard1(this->lock_); 54 0 : if (unbind(map_, link->id()) != 0) { 55 : // Just report to the log that we tried. 56 0 : VDBG((LM_DEBUG, 57 : ACE_TEXT("(%P|%t) DataLinkSet::remove_links: ") 58 : ACE_TEXT("link_id %d not found in map.\n"), 59 : link->id())); 60 : } 61 0 : } 62 : 63 : OpenDDS::DCPS::DataLinkSet_rch 64 0 : OpenDDS::DCPS::DataLinkSet::select_links(const GUID_t* remoteIds, 65 : const CORBA::ULong num_targets) 66 : { 67 : DBG_ENTRY_LVL("DataLinkSet","select_links",6); 68 : 69 0 : DataLinkSet_rch selected_links ( make_rch<DataLinkSet>() ); 70 0 : GuardType guard(this->lock_); 71 0 : for (MapType::iterator itr = map_.begin(); 72 0 : itr != map_.end(); 73 0 : ++itr) { 74 0 : for (CORBA::ULong i = 0; i < num_targets; ++i) { 75 0 : if (itr->second->is_target(remoteIds[i])) { 76 0 : OpenDDS::DCPS::bind(selected_links->map_, 77 0 : itr->second->id(), itr->second); 78 0 : break; 79 : } 80 : } 81 : } 82 : 83 0 : return selected_links; 84 0 : } 85 : 86 : bool 87 0 : OpenDDS::DCPS::DataLinkSet::empty() 88 : { 89 0 : GuardType guard(this->lock_); 90 : 91 0 : return map_.empty(); 92 0 : } 93 : 94 0 : void OpenDDS::DCPS::DataLinkSet::terminate_send_if_suspended() 95 : { 96 0 : MapType map_copy; 97 : { 98 0 : GuardType guard(lock_); 99 0 : map_copy = map_; 100 0 : } 101 0 : for (MapType::iterator itr = map_copy.begin(); 102 0 : itr != map_copy.end(); ++itr) { 103 0 : itr->second->terminate_send_if_suspended(); 104 : } 105 0 : } 106 : 107 0 : bool OpenDDS::DCPS::DataLinkSet::is_leading(const GUID_t& writer_id, 108 : const GUID_t& reader_id) const 109 : { 110 0 : GuardType guard(this->lock_); 111 0 : for (MapType::const_iterator pos = map_.begin(), limit = map_.end(); pos != limit; ++pos) { 112 0 : if (pos->second->is_leading(writer_id, reader_id)) { 113 0 : return true; 114 : } 115 : } 116 : 117 0 : return false; 118 0 : }