OpenDDS  Snapshot(2023/04/28-20:55)
ShmemDataLink.h
Go to the documentation of this file.
1 /*
2  * Distributed under the OpenDDS License.
3  * See: http://www.opendds.org/license.html
4  */
5 
6 #ifndef OPENDDS_DCPS_TRANSPORT_SHMEM_SHMEMDATALINK_H
7 #define OPENDDS_DCPS_TRANSPORT_SHMEM_SHMEMDATALINK_H
8 
9 #include "Shmem_Export.h"
10 #include "ShmemAllocator.h"
11 #include "ShmemReceiveStrategy.h"
13 #include "ShmemSendStrategy.h"
14 #include "ShmemSendStrategy_rch.h"
15 #include "ShmemTransport_rch.h"
16 
17 #include <dds/DCPS/GuidUtils.h>
18 #include <dds/DCPS/PeriodicTask.h>
20 
21 #include <string>
22 #include <set>
23 
25 
26 namespace OpenDDS {
27 namespace DCPS {
28 
29 class ReceivedDataSample;
30 
31 struct ShmemData {
32  enum Status {
33  Free = 0,
34  InUse = 1,
35  RecvDone = 2,
37  };
38 
39  /*
40  * This is ACE_INT8 instead of Status to try to make the in-memory
41  * representation independent of compiler/implementation decisions. We can't
42  * guarantee that two processes running code built with different compilers
43  * can communicate over shmem, but we'll try to support it when possible.
44  */
48 };
49 
51  : public DataLink {
52 public:
53 
54  ShmemDataLink(const ShmemTransport_rch& transport);
55 
56  bool open(const std::string& peer_address);
57 
58  int make_reservation(const GUID_t& remote_pub,
59  const GUID_t& local_sub,
60  const TransportReceiveListener_wrch& receive_listener,
61  bool reliable);
62 
63  void request_ack_received(ReceivedDataSample& sample);
64  void stop_resend_association_msgs(const GUID_t& local, const GUID_t& remote);
65 
66  void control_received(ReceivedDataSample& sample);
67 
68  std::string local_address();
69  std::string peer_address();
70  pid_t peer_pid();
71 
72  ShmemAllocator* local_allocator();
73  ShmemAllocator* peer_allocator();
74 
75  void read() { recv_strategy_->read(); }
76  void signal_semaphore();
77  ShmemTransport_rch transport() const;
78  ShmemInst_rch config() const;
79 
80 protected:
83 
84  virtual void stop_i();
85 
86 private:
87  void send_association_msg(const GUID_t& local, const GUID_t& remote);
88  void resend_association_msgs(const MonotonicTimePoint& now);
89 
90  std::string peer_address_;
94 
96  typedef std::set<GuidPair> AssocResends;
97  AssocResends assoc_resends_;
100 };
101 
102 } // namespace DCPS
103 } // namespace OpenDDS
104 
106 
107 #ifdef __ACE_INLINE__
108 # include "ShmemDataLink.inl"
109 #endif /* __ACE_INLINE__ */
110 
111 #endif /* OPENDDS_SHMEMDATALINK_H */
ShmemSendStrategy_rch send_strategy_
Definition: ShmemDataLink.h:81
ACE_Thread_Mutex assoc_resends_mutex_
Definition: ShmemDataLink.h:95
DCPS::RcHandle< SmPeriodicTask > assoc_resends_task_
Definition: ShmemDataLink.h:99
ShmemReceiveStrategy_rch recv_strategy_
Definition: ShmemDataLink.h:82
signed char ACE_INT8
ACE_Thread_Mutex peer_alloc_mutex_
Definition: ShmemDataLink.h:92
static const ACE_UINT32 TRANSPORT_HDR_SERIALIZED_SZ(28)
ACE_HANDLE open(const char *filename, int mode, mode_t perms=ACE_DEFAULT_OPEN_PERMS, LPSECURITY_ATTRIBUTES sa=0)
Holds a data sample received by the transport.
char transport_header_[TRANSPORT_HDR_SERIALIZED_SZ]
Definition: ShmemDataLink.h:46
ACE_Based_Pointer_Basic< char > payload_
Definition: ShmemDataLink.h:47
ShmemAllocator * peer_alloc_
Definition: ShmemDataLink.h:91
std::set< GuidPair > AssocResends
Definition: ShmemDataLink.h:96
#define OPENDDS_END_VERSIONED_NAMESPACE_DECL
PmfPeriodicTask< ShmemDataLink > SmPeriodicTask
Definition: ShmemDataLink.h:98
The Internal API and Implementation of OpenDDS.
Definition: AddressCache.h:28
ReactorTask_rch reactor_task_
Definition: ShmemDataLink.h:93
#define OpenDDS_Shmem_Export
Definition: Shmem_Export.h:25