00001
00002
00003
00004
00005
00006
00007
00008 #ifndef OPENDDS_SHMEMTRANSPORT_H
00009 #define OPENDDS_SHMEMTRANSPORT_H
00010
00011 #include "Shmem_Export.h"
00012
00013 #include "ShmemDataLink.h"
00014 #include "ShmemDataLink_rch.h"
00015
00016 #include "dds/DCPS/transport/framework/TransportImpl.h"
00017 #include "dds/DCPS/PoolAllocator.h"
00018
00019 #include <string>
00020
00021 namespace OpenDDS {
00022 namespace DCPS {
00023
00024 class ShmemInst;
00025
00026 class OpenDDS_Shmem_Export ShmemTransport : public TransportImpl {
00027 public:
00028 explicit ShmemTransport(const TransportInst_rch& inst);
00029
00030
00031 ShmemAllocator* alloc() { return alloc_; }
00032 std::string address();
00033 void signal_semaphore();
00034
00035 protected:
00036 virtual AcceptConnectResult connect_datalink(const RemoteTransport& remote,
00037 const ConnectionAttribs& attribs,
00038 TransportClient* client);
00039
00040 virtual AcceptConnectResult accept_datalink(const RemoteTransport& remote,
00041 const ConnectionAttribs& attribs,
00042 TransportClient* client);
00043
00044 virtual void stop_accepting_or_connecting(TransportClient* client,
00045 const RepoId& remote_id);
00046
00047 virtual bool configure_i(TransportInst* config);
00048
00049 virtual void shutdown_i();
00050
00051 virtual bool connection_info_i(TransportLocator& info) const;
00052
00053 virtual void release_datalink(DataLink* link);
00054
00055 virtual std::string transport_type() const { return "shmem"; }
00056
00057 private:
00058
00059
00060 DataLink* add_datalink(const std::string& remote_address);
00061
00062
00063 ShmemDataLink* make_datalink(const std::string& remote_address);
00064
00065 std::pair<std::string, std::string> blob_to_key(const TransportBLOB& blob);
00066
00067 void read_from_links();
00068
00069 RcHandle<ShmemInst> config_i_;
00070
00071 typedef ACE_Thread_Mutex LockType;
00072 typedef ACE_Guard<LockType> GuardType;
00073
00074 LockType links_lock_;
00075
00076
00077
00078 typedef OPENDDS_MAP(std::string, ShmemDataLink_rch) ShmemDataLinkMap;
00079 ShmemDataLinkMap links_;
00080
00081 ShmemAllocator* alloc_;
00082
00083 struct ReadTask : ACE_Task_Base {
00084 ReadTask(ShmemTransport* outer, ACE_sema_t semaphore);
00085 int svc();
00086 void stop();
00087
00088 ShmemTransport* outer_;
00089 ACE_sema_t semaphore_;
00090 bool stopped_;
00091
00092 }* read_task_;
00093 };
00094
00095 }
00096 }
00097
00098 #endif