OpenDDS  Snapshot(2023/04/07-19:43)
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
OpenDDS::DCPS::ShmemTransport Class Reference

#include <ShmemTransport.h>

Inheritance diagram for OpenDDS::DCPS::ShmemTransport:
Inheritance graph
[legend]
Collaboration diagram for OpenDDS::DCPS::ShmemTransport:
Collaboration graph
[legend]

Classes

class  ReadTask
 

Public Member Functions

 ShmemTransport (const ShmemInst_rch &inst)
 
ShmemAllocatoralloc ()
 
std::string address ()
 
void signal_semaphore ()
 
ShmemInst_rch config () const
 
- Public Member Functions inherited from OpenDDS::DCPS::TransportImpl
virtual ~TransportImpl ()
 
virtual void unbind_link (DataLink *link)
 Remove any pending_release mappings. More...
 
bool release_link_resources (DataLink *link)
 
TransportInst_rch config () const
 
virtual void register_for_reader (const GUID_t &, const GUID_t &, const GUID_t &, const TransportLocatorSeq &, OpenDDS::DCPS::DiscoveryListener *)
 
virtual void unregister_for_reader (const GUID_t &, const GUID_t &, const GUID_t &)
 
virtual void register_for_writer (const GUID_t &, const GUID_t &, const GUID_t &, const TransportLocatorSeq &, DiscoveryListener *)
 
virtual void unregister_for_writer (const GUID_t &, const GUID_t &, const GUID_t &)
 
virtual void update_locators (const GUID_t &, const TransportLocatorSeq &)
 
virtual void get_last_recv_locator (const GUID_t &, TransportLocator &)
 
virtual void rtps_relay_address_change ()
 
virtual void append_transport_statistics (TransportStatisticsSequence &)
 
ACE_Reactor_Timer_Interfacetimer () const
 Interface to the transport's reactor for scheduling timers. More...
 
ACE_Reactorreactor () const
 
ACE_thread_t reactor_owner () const
 
bool is_shut_down () const
 
void create_reactor_task (bool useAsyncSend=false, const OPENDDS_STRING &name="")
 
void dump ()
 Diagnostic aid. More...
 
OPENDDS_STRING dump_to_str ()
 
void report ()
 
virtual WeakRcHandle< ICE::Endpointget_ice_endpoint ()
 
virtual void rtps_relay_only_now (bool)
 
virtual void use_rtps_relay_now (bool)
 
virtual void use_ice_now (bool)
 
ReactorTask_rch reactor_task ()
 
EventDispatcher_rch event_dispatcher ()
 
int acquire ()
 
int tryacquire ()
 
int release ()
 
int remove ()
 
bool connection_info (TransportLocator &local_info, ConnectionInfoFlags flags) const
 
- Public Member Functions inherited from OpenDDS::DCPS::RcObject
virtual ~RcObject ()
 
virtual void _add_ref ()
 
virtual void _remove_ref ()
 
long ref_count () const
 
WeakObject_get_weak_object () const
 

Protected Member Functions

virtual AcceptConnectResult connect_datalink (const RemoteTransport &remote, const ConnectionAttribs &attribs, const TransportClient_rch &client)
 
virtual AcceptConnectResult accept_datalink (const RemoteTransport &remote, const ConnectionAttribs &attribs, const TransportClient_rch &client)
 
virtual void stop_accepting_or_connecting (const TransportClient_wrch &client, const GUID_t &remote_id, bool disassociate, bool association_failed)
 
bool configure_i (const ShmemInst_rch &config)
 
virtual void shutdown_i ()
 
virtual bool connection_info_i (TransportLocator &info, ConnectionInfoFlags flags) const
 
virtual void release_datalink (DataLink *link)
 
virtual std::string transport_type () const
 
- Protected Member Functions inherited from OpenDDS::DCPS::TransportImpl
 TransportImpl (TransportInst_rch config)
 
bool open ()
 
typedef OPENDDS_MULTIMAP (TransportClient_wrch, DataLink_rch) PendConnMap
 
void add_pending_connection (const TransportClient_rch &client, DataLink_rch link)
 
void shutdown ()
 
- Protected Member Functions inherited from OpenDDS::DCPS::RcObject
 RcObject ()
 

Private Types

typedef ACE_Thread_Mutex LockType
 
typedef ACE_Guard< LockTypeGuardType
 

Private Member Functions

ShmemDataLink_rch make_datalink (const std::string &remote_address)
 Create the DataLink object and start it. More...
 
ShmemDataLink_rch get_or_make_datalink (const char *caller, const RemoteTransport &remote)
 
std::pair< std::string, std::string > blob_to_key (const TransportBLOB &blob)
 
void read_from_links ()
 
typedef OPENDDS_MAP (std::string, ShmemDataLink_rch) ShmemDataLinkMap
 

Private Attributes

LockType links_lock_
 
ShmemDataLinkMap links_
 
unique_ptr< ShmemAllocatoralloc_
 
unique_ptr< ReadTaskread_task_
 

Additional Inherited Members

- Public Attributes inherited from OpenDDS::DCPS::TransportImpl
LockType lock_
 Lock to protect the config_ and reactor_task_ data members. More...
 
WeakRcHandle< TransportInstconfig_
 
ReactorTask_rch reactor_task_
 
EventDispatcher_rch event_dispatcher_
 smart ptr to the associated DL cleanup task More...
 
unique_ptr< Monitormonitor_
 Monitor object for this entity. More...
 
- Protected Types inherited from OpenDDS::DCPS::TransportImpl
typedef ACE_SYNCH_MUTEX LockType
 
typedef ACE_Guard< LockTypeGuardType
 
- Protected Attributes inherited from OpenDDS::DCPS::TransportImpl
LockType pending_connections_lock_
 Lock to protect the pending_connections_ data member. More...
 
PendConnMap pending_connections_
 
AtomicBool is_shut_down_
 Id of the last link established. More...
 

Detailed Description

Definition at line 27 of file ShmemTransport.h.

Member Typedef Documentation

◆ GuardType

Definition at line 73 of file ShmemTransport.h.

◆ LockType

Definition at line 72 of file ShmemTransport.h.

Constructor & Destructor Documentation

◆ ShmemTransport()

OpenDDS::DCPS::ShmemTransport::ShmemTransport ( const ShmemInst_rch inst)
explicit

Definition at line 28 of file ShmemTransport.cpp.

References configure_i(), and OpenDDS::DCPS::TransportImpl::open().

29  : TransportImpl(inst)
30 {
31  if (!(configure_i(inst) && open())) {
32  throw Transport::UnableToCreate();
33  }
34 }
bool configure_i(const ShmemInst_rch &config)
TransportImpl(TransportInst_rch config)

Member Function Documentation

◆ accept_datalink()

TransportImpl::AcceptConnectResult OpenDDS::DCPS::ShmemTransport::accept_datalink ( const RemoteTransport remote,
const ConnectionAttribs attribs,
const TransportClient_rch client 
)
protectedvirtual

accept_datalink() is called from TransportClient to initiate an association as the passive peer. A DataLink may be returned if one is already connected and ready to use, otherwise passively wait for a physical connection from the active side (either in the form of a connection event or handshaking message). Upon completion of the physical connection, the transport calls back to TransportClient::use_datalink().

Implements OpenDDS::DCPS::TransportImpl.

Definition at line 107 of file ShmemTransport.cpp.

References get_or_make_datalink().

110 {
111  return AcceptConnectResult(get_or_make_datalink("accept_datalink", remote));
112 }
ShmemDataLink_rch get_or_make_datalink(const char *caller, const RemoteTransport &remote)

◆ address()

std::string OpenDDS::DCPS::ShmemTransport::address ( void  )

Definition at line 356 of file ShmemTransport.cpp.

References config(), and OPENDDS_END_VERSIONED_NAMESPACE_DECL.

357 {
358  ShmemInst_rch cfg = config();
359  return cfg ? cfg->poolname() : std::string();
360 }
ShmemInst_rch config() const
RcHandle< ShmemInst > ShmemInst_rch
Definition: ShmemInst_rch.h:18

◆ alloc()

ShmemAllocator* OpenDDS::DCPS::ShmemTransport::alloc ( void  )
inline

Definition at line 32 of file ShmemTransport.h.

32 { return alloc_.get(); }
unique_ptr< ShmemAllocator > alloc_

◆ blob_to_key()

std::pair< std::string, std::string > OpenDDS::DCPS::ShmemTransport::blob_to_key ( const TransportBLOB blob)
private

Definition at line 258 of file ShmemTransport.cpp.

Referenced by get_or_make_datalink().

259 {
260  const char* const c_str = reinterpret_cast<const char*>(blob.get_buffer());
261  const std::string host(c_str);
262  const size_t host_len = host.size();
263 
264  const std::string pool(c_str + host_len + 1, blob.length() - host_len - 1);
265  return make_pair(host, pool);
266 }

◆ config()

ShmemInst_rch OpenDDS::DCPS::ShmemTransport::config ( ) const

Definition at line 37 of file ShmemTransport.cpp.

References OpenDDS::DCPS::TransportImpl::config(), and OpenDDS::DCPS::dynamic_rchandle_cast().

Referenced by address(), connection_info_i(), and get_or_make_datalink().

38 {
39  return dynamic_rchandle_cast<ShmemInst>(TransportImpl::config());
40 }
RcHandle< T > dynamic_rchandle_cast(const RcHandle< U > &h)
Definition: RcHandle_T.h:214
TransportInst_rch config() const

◆ configure_i()

bool OpenDDS::DCPS::ShmemTransport::configure_i ( const ShmemInst_rch config)
protected

Definition at line 133 of file ShmemTransport.cpp.

References ACE_ERROR, ACE_ERROR_RETURN, ACE_TEXT(), ACE_TEXT_CHAR_TO_TCHAR, alloc_, OpenDDS::DCPS::TransportImpl::create_reactor_task(), OpenDDS::DCPS::LogLevel::Error, LM_DEBUG, LM_ERROR, OpenDDS::DCPS::log_level, read_task_, and VDBG_LVL.

Referenced by ShmemTransport().

134 {
135  if (!config) {
136  return false;
137  }
138 
139  create_reactor_task(false, "ShmemTransport" + config->name());
140 
141 #ifdef OPENDDS_SHMEM_UNSUPPORTED
142  ACE_UNUSED_ARG(config);
143  if (log_level >= LogLevel::Error) {
144  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: ShmemTransport::configure_i: "
145  "no platform support for shared memory!\n"));
146  }
147  return false;
148 #else /* OPENDDS_SHMEM_UNSUPPORTED */
149 
151 # if defined OPENDDS_SHMEM_WINDOWS
152  alloc_opts.max_size_ = config->pool_size_;
153 # elif defined OPENDDS_SHMEM_UNIX
154  alloc_opts.base_addr_ = 0;
155  alloc_opts.segment_size_ = config->pool_size_;
156  alloc_opts.minimum_bytes_ = alloc_opts.segment_size_;
157  alloc_opts.max_segments_ = 1;
158 # endif /* OPENDDS_SHMEM_WINDOWS */
159 
160  alloc_.reset(
161  new ShmemAllocator(ACE_TEXT_CHAR_TO_TCHAR(config->poolname().c_str()),
162  0 /*lock_name is optional*/, &alloc_opts));
163 
164  void* mem = alloc_->malloc(sizeof(ShmemSharedSemaphore));
165  if (mem == 0) {
166  if (log_level >= LogLevel::Error) {
167  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: ShmemTrasport::configure_i: failed to allocate"
168  " space for semaphore in shared memory!\n"));
169  }
170  return false;
171  }
172 
173  ShmemSharedSemaphore* pSem = reinterpret_cast<ShmemSharedSemaphore*>(mem);
174  alloc_->bind("Semaphore", pSem);
175 
176  bool ok;
177 # if defined OPENDDS_SHMEM_WINDOWS
178  *pSem = ::CreateSemaphoreW(0 /*default security*/,
179  0 /*initial count*/,
180  0x7fffffff /*max count (ACE's default)*/,
181  0 /*no name*/);
182  ACE_sema_t ace_sema = *pSem;
183  ok = (*pSem != 0);
184 # elif defined OPENDDS_SHMEM_UNIX
185  ok = (0 == ::sem_init(pSem, 1 /*process shared*/, 0 /*initial count*/));
186  ACE_sema_t ace_sema;
187  std::memset(&ace_sema, 0, sizeof ace_sema);
188  ace_sema.sema_ = pSem;
189 # ifdef OPENDDS_SHMEM_UNIX_EMULATE_SEM_TIMEOUT
190  ace_sema.lock_ = PTHREAD_MUTEX_INITIALIZER;
191  ace_sema.count_nonzero_ = PTHREAD_COND_INITIALIZER;
192 # endif
193 # endif /* OPENDDS_SHMEM_WINDOWS */
194  if (!ok) {
195  ACE_ERROR_RETURN((LM_ERROR, ACE_TEXT("(%P|%t) ERROR: ")
196  ACE_TEXT("ShmemTransport::configure_i: ")
197  ACE_TEXT("could not create semaphore\n")),
198  false);
199  }
200 
201  read_task_.reset(new ReadTask(this, ace_sema));
202 
203  VDBG_LVL((LM_DEBUG, "(%P|%t) ShmemTransport %@ configured with address %C\n",
204  this, config->poolname().c_str()), 1);
205 
206  return true;
207 #endif /* OPENDDS_SHMEM_UNSUPPORTED */
208 }
OpenDDS_Dcps_Export LogLevel log_level
ShmemInst_rch config() const
#define ACE_ERROR(X)
ACE_MEM_POOL_OPTIONS MEMORY_POOL_OPTIONS
unique_ptr< ReadTask > read_task_
ACE_Malloc_T< ShmemPool, ACE_Process_Mutex, ACE_PI_Control_Block > ShmemAllocator
int ShmemSharedSemaphore
#define ACE_TEXT_CHAR_TO_TCHAR(STRING)
ACE_TEXT("TCP_Factory")
unique_ptr< ShmemAllocator > alloc_
#define VDBG_LVL(DBG_ARGS, LEVEL)
void create_reactor_task(bool useAsyncSend=false, const OPENDDS_STRING &name="")
#define ACE_ERROR_RETURN(X, Y)

◆ connect_datalink()

TransportImpl::AcceptConnectResult OpenDDS::DCPS::ShmemTransport::connect_datalink ( const RemoteTransport remote,
const ConnectionAttribs attribs,
const TransportClient_rch client 
)
protectedvirtual

connect_datalink() is called from TransportClient to initiate an association as the active peer. A DataLink may be returned if one is already connected and ready to use, otherwise initiate a connection to the passive side and return from this method. Upon completion of the physical connection, the transport calls back to TransportClient::use_datalink().

Implements OpenDDS::DCPS::TransportImpl.

Definition at line 90 of file ShmemTransport.cpp.

References OpenDDS::DCPS::TransportImpl::AcceptConnectResult::ACR_SUCCESS, OpenDDS::DCPS::TransportImpl::add_pending_connection(), get_or_make_datalink(), and OpenDDS::DCPS::TransportImpl::RemoteTransport::repo_id_.

93 {
94  ShmemDataLink_rch link = get_or_make_datalink("connect_datalink", remote);
95  if (!link) {
96  return AcceptConnectResult();
97  }
98  // Wait for invoke_on_start_callbacks to actually start a writer. This is done
99  // when the writer gets an association message from the reader in the writer
100  // case of ShmemDataLink::request_ack_received.
101  link->add_on_start_callback(client, remote.repo_id_);
102  add_pending_connection(client, link);
103  return AcceptConnectResult(AcceptConnectResult::ACR_SUCCESS);
104 }
RcHandle< ShmemDataLink > ShmemDataLink_rch
void add_pending_connection(const TransportClient_rch &client, DataLink_rch link)
ShmemDataLink_rch get_or_make_datalink(const char *caller, const RemoteTransport &remote)

◆ connection_info_i()

bool OpenDDS::DCPS::ShmemTransport::connection_info_i ( TransportLocator local_info,
ConnectionInfoFlags  flags 
) const
protectedvirtual

Called by our connection_info() method to allow the concrete TransportImpl subclass to do the dirty work since it really is the one that knows how to populate the supplied TransportLocator object.

Implements OpenDDS::DCPS::TransportImpl.

Definition at line 247 of file ShmemTransport.cpp.

References config().

248 {
249  ShmemInst_rch cfg = config();
250  if (cfg) {
251  cfg->populate_locator(info, flags);
252  return true;
253  }
254  return false;
255 }
ShmemInst_rch config() const
RcHandle< ShmemInst > ShmemInst_rch
Definition: ShmemInst_rch.h:18

◆ get_or_make_datalink()

ShmemDataLink_rch OpenDDS::DCPS::ShmemTransport::get_or_make_datalink ( const char *  caller,
const RemoteTransport remote 
)
private

Definition at line 66 of file ShmemTransport.cpp.

References ACE_ERROR, OpenDDS::DCPS::TransportImpl::RemoteTransport::blob_, blob_to_key(), config(), OpenDDS::DCPS::LogLevel::Error, links_, links_lock_, LM_DEBUG, LM_ERROR, OpenDDS::DCPS::log_level, make_datalink(), and VDBG_LVL.

Referenced by accept_datalink(), and connect_datalink().

68 {
69  const std::pair<std::string, std::string> key = blob_to_key(remote.blob_);
70  ShmemInst_rch cfg = config();
71  if (!cfg || key.first != cfg->hostname()) {
72  if (log_level >= LogLevel::Error) {
73  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: ShmemTransport::get_or_make_datalink: "
74  "%C link %C:%C not found, hostname %C.\n",
75  caller, key.first.c_str(), key.second.c_str(),
76  cfg ? cfg->hostname().c_str() : "(no config)"));
77  }
78  return ShmemDataLink_rch();
79  }
80 
81  GuardType guard(links_lock_);
82  ShmemDataLinkMap::iterator iter = links_.find(key.second);
83  const bool make = iter == links_.end();
84  VDBG_LVL((LM_DEBUG, "(%P|%t) ShmemTransport::get_or_make_datalink: %C using %C link %C:%C\n",
85  caller, make ? "new" : "existing", key.first.c_str(), key.second.c_str()), 2);
86  return make ? make_datalink(key.second) : iter->second;
87 }
OpenDDS_Dcps_Export LogLevel log_level
ShmemInst_rch config() const
#define ACE_ERROR(X)
sequence< octet > key
ACE_Guard< LockType > GuardType
RcHandle< ShmemDataLink > ShmemDataLink_rch
RcHandle< ShmemInst > ShmemInst_rch
Definition: ShmemInst_rch.h:18
std::pair< std::string, std::string > blob_to_key(const TransportBLOB &blob)
#define VDBG_LVL(DBG_ARGS, LEVEL)
ShmemDataLink_rch make_datalink(const std::string &remote_address)
Create the DataLink object and start it.

◆ make_datalink()

ShmemDataLink_rch OpenDDS::DCPS::ShmemTransport::make_datalink ( const std::string &  remote_address)
private

Create the DataLink object and start it.

Definition at line 43 of file ShmemTransport.cpp.

References ACE_ERROR, OpenDDS::DCPS::LogLevel::Error, links_, LM_ERROR, OpenDDS::DCPS::log_level, and OpenDDS::DCPS::rchandle_from().

Referenced by get_or_make_datalink().

44 {
45  ShmemDataLink_rch link = make_rch<ShmemDataLink>(rchandle_from(this));
46 
47  if (!link->open(remote_address)) {
48  if (log_level >= LogLevel::Error) {
49  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: ShmemTransport::make_datalink: "
50  "failed to open DataLink!\n"));
51  }
52  return ShmemDataLink_rch();
53  }
54 
55  if (!links_.insert(ShmemDataLinkMap::value_type(remote_address, link)).second) {
56  if (log_level >= LogLevel::Error) {
57  ACE_ERROR((LM_ERROR, "(%P|%t) ERROR: ShmemTransport::make_datalink: "
58  "there is an existing link for %C!\n", remote_address.c_str()));
59  }
60  return ShmemDataLink_rch();
61  }
62 
63  return link;
64 }
OpenDDS_Dcps_Export LogLevel log_level
#define ACE_ERROR(X)
RcHandle< ShmemDataLink > ShmemDataLink_rch
RcHandle< T > rchandle_from(T *pointer)
Definition: RcHandle_T.h:310

◆ OPENDDS_MAP()

typedef OpenDDS::DCPS::ShmemTransport::OPENDDS_MAP ( std::string  ,
ShmemDataLink_rch   
)
private

Map of fully associated DataLinks for this transport. Protected by links_lock_.

◆ read_from_links()

void OpenDDS::DCPS::ShmemTransport::read_from_links ( )
private

Definition at line 329 of file ShmemTransport.cpp.

References OpenDDS::DCPS::TransportImpl::is_shut_down(), links_, and links_lock_.

Referenced by OpenDDS::DCPS::ShmemTransport::ReadTask::svc().

330 {
331  std::vector<ShmemDataLink_rch> dl_copies;
332  {
333  GuardType guard(links_lock_);
334  typedef ShmemDataLinkMap::iterator iter_t;
335  for (iter_t it = links_.begin(); it != links_.end(); ++it) {
336  dl_copies.push_back(it->second);
337  }
338  }
339 
340  typedef std::vector<ShmemDataLink_rch>::iterator dl_iter_t;
341  for (dl_iter_t dl_it = dl_copies.begin(); !is_shut_down() && dl_it != dl_copies.end(); ++dl_it) {
342  dl_it->in()->read();
343  }
344 }
ACE_Guard< LockType > GuardType

◆ release_datalink()

void OpenDDS::DCPS::ShmemTransport::release_datalink ( DataLink link)
protectedvirtual

Called by the TransportRegistry when this TransportImpl object is released while the TransportRegistry is handling a release() "event". The DataLink itself calls this method when it thinks it is no longer used for any associations. This occurs during a "remove associations" operation being performed by some TransportClient that uses this TransportImpl. The TransportClient is known to have acquired our reservation_lock_, so there won't be any reserve_datalink() calls being made from any other threads while we perform this release.

Implements OpenDDS::DCPS::TransportImpl.

Definition at line 269 of file ShmemTransport.cpp.

References links_, links_lock_, and OpenDDS::DCPS::DataLink::stop().

270 {
271  GuardType guard(links_lock_);
272  for (ShmemDataLinkMap::iterator it(links_.begin());
273  it != links_.end(); ++it) {
274  // We are guaranteed to have exactly one matching DataLink
275  // in the map; release any resources held and return.
276  if (link == static_cast<DataLink*>(it->second.in())) {
277  link->stop();
278  links_.erase(it);
279  return;
280  }
281  }
282 }
ACE_Guard< LockType > GuardType

◆ shutdown_i()

void OpenDDS::DCPS::ShmemTransport::shutdown_i ( )
protectedvirtual

Called during the shutdown() method in order to give the concrete TransportImpl subclass a chance to do something when the shutdown "event" occurs.

Implements OpenDDS::DCPS::TransportImpl.

Definition at line 211 of file ShmemTransport.cpp.

References alloc_, links_, links_lock_, read_task_, and TheServiceParticipant.

212 {
213  if (read_task_) {
214  read_task_->stop();
215  ThreadStatusManager::Sleeper s(TheServiceParticipant->get_thread_status_manager());
216  read_task_->wait();
217  }
218 
219  // Shutdown reserved datalinks and release configuration:
220  GuardType guard(links_lock_);
221  for (ShmemDataLinkMap::iterator it(links_.begin());
222  it != links_.end(); ++it) {
223  it->second->transport_shutdown();
224  }
225  links_.clear();
226 
227  read_task_.reset();
228 
229  if (alloc_) {
230 #ifndef OPENDDS_SHMEM_UNSUPPORTED
231  void* mem = 0;
232  alloc_->find("Semaphore", mem);
233  ShmemSharedSemaphore* pSem = reinterpret_cast<ShmemSharedSemaphore*>(mem);
234 # if defined OPENDDS_SHMEM_WINDOWS
235  ::CloseHandle(*pSem);
236 # elif defined OPENDDS_SHMEM_UNIX
237  ::sem_destroy(pSem);
238 # endif /* OPENDDS_SHMEM_WINDOWS */
239 #endif /* OPENDDS_SHMEM_UNSUPPORTED */
240 
241  alloc_->release(1 /*close*/);
242  alloc_.reset();
243  }
244 }
unique_ptr< ReadTask > read_task_
ACE_Guard< LockType > GuardType
int ShmemSharedSemaphore
unique_ptr< ShmemAllocator > alloc_
#define TheServiceParticipant

◆ signal_semaphore()

void OpenDDS::DCPS::ShmemTransport::signal_semaphore ( )

Definition at line 347 of file ShmemTransport.cpp.

References OpenDDS::DCPS::TransportImpl::is_shut_down(), and read_task_.

348 {
349  if (is_shut_down()) {
350  return;
351  }
352  read_task_->signal_semaphore();
353 }
unique_ptr< ReadTask > read_task_

◆ stop_accepting_or_connecting()

void OpenDDS::DCPS::ShmemTransport::stop_accepting_or_connecting ( const TransportClient_wrch client,
const GUID_t remote_id,
bool  disassociate,
bool  association_failed 
)
protectedvirtual

stop_accepting_or_connecting() is called from TransportClient to terminate the accepting process begun by accept_datalink() or connect_datalink(). This allows the TransportImpl to clean up any resources associated with this pending connection. The TransportClient* passed in to accept or connect is not valid after this method is called.

Implements OpenDDS::DCPS::TransportImpl.

Definition at line 114 of file ShmemTransport.cpp.

References ACE_GUARD, OpenDDS::DCPS::dynamic_rchandle_cast(), links_lock_, OpenDDS::DCPS::WeakRcHandle< T >::lock(), OpenDDS::DCPS::TransportImpl::pending_connections_, and OpenDDS::DCPS::TransportImpl::pending_connections_lock_.

117 {
118  ACE_GUARD(ACE_Thread_Mutex, links_guard, links_lock_);
120  typedef PendConnMap::iterator Iter;
121  const std::pair<Iter, Iter> range = pending_connections_.equal_range(client);
122  for (Iter iter = range.first; iter != range.second; ++iter) {
123  ShmemDataLink_rch sdl = dynamic_rchandle_cast<ShmemDataLink>(iter->second);
124  TransportClient_rch tc = client.lock();
125  if (tc) {
126  sdl->stop_resend_association_msgs(tc->get_guid(), remote_id);
127  }
128  }
129  pending_connections_.erase(range.first, range.second);
130 }
#define ACE_GUARD(MUTEX, OBJ, LOCK)
RcHandle< TransportClient > TransportClient_rch
RcHandle< ShmemDataLink > ShmemDataLink_rch
RcHandle< T > dynamic_rchandle_cast(const RcHandle< U > &h)
Definition: RcHandle_T.h:214
LockType pending_connections_lock_
Lock to protect the pending_connections_ data member.

◆ transport_type()

virtual std::string OpenDDS::DCPS::ShmemTransport::transport_type ( ) const
inlineprotectedvirtual

Implements OpenDDS::DCPS::TransportImpl.

Definition at line 60 of file ShmemTransport.h.

60 { return "shmem"; }

Member Data Documentation

◆ alloc_

unique_ptr<ShmemAllocator> OpenDDS::DCPS::ShmemTransport::alloc_
private

Definition at line 82 of file ShmemTransport.h.

Referenced by configure_i(), and shutdown_i().

◆ links_

ShmemDataLinkMap OpenDDS::DCPS::ShmemTransport::links_
private

◆ links_lock_

LockType OpenDDS::DCPS::ShmemTransport::links_lock_
private

◆ read_task_

unique_ptr<ReadTask> OpenDDS::DCPS::ShmemTransport::read_task_
private

Definition at line 96 of file ShmemTransport.h.

Referenced by configure_i(), shutdown_i(), and signal_semaphore().


The documentation for this class was generated from the following files: