FairMQ  1.3.9
C++ Message Passing Framework
FairMQSocketSHM.h
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 #ifndef FAIRMQSOCKETSHM_H_
9 #define FAIRMQSOCKETSHM_H_
10 
11 #include "FairMQSocket.h"
12 #include "FairMQMessage.h"
13 
14 #include <fairmq/shmem/Manager.h>
15 
16 #include <atomic>
17 #include <memory> // unique_ptr
19 
20 class FairMQSocketSHM final : public FairMQSocket
21 {
22  public:
23  FairMQSocketSHM(fair::mq::shmem::Manager& manager, const std::string& type, const std::string& name, const std::string& id = "", void* context = nullptr, FairMQTransportFactory* fac = nullptr);
24  FairMQSocketSHM(const FairMQSocketSHM&) = delete;
25  FairMQSocketSHM operator=(const FairMQSocketSHM&) = delete;
26 
27  std::string GetId() override { return fId; }
28 
29  bool Bind(const std::string& address) override;
30  bool Connect(const std::string& address) override;
31 
32  int Send(FairMQMessagePtr& msg, const int timeout = -1) override;
33  int Receive(FairMQMessagePtr& msg, const int timeout = -1) override;
34  int64_t Send(std::vector<std::unique_ptr<FairMQMessage>>& msgVec, const int timeout = -1) override;
35  int64_t Receive(std::vector<std::unique_ptr<FairMQMessage>>& msgVec, const int timeout = -1) override;
36 
37  void* GetSocket() const;
38 
39  void Close() override;
40 
41  static void Interrupt();
42  static void Resume();
43 
44  void SetOption(const std::string& option, const void* value, size_t valueSize) override;
45  void GetOption(const std::string& option, void* value, size_t* valueSize) override;
46 
47  void SetLinger(const int value) override;
48  int GetLinger() const override;
49  void SetSndBufSize(const int value) override;
50  int GetSndBufSize() const override;
51  void SetRcvBufSize(const int value) override;
52  int GetRcvBufSize() const override;
53  void SetSndKernelSize(const int value) override;
54  int GetSndKernelSize() const override;
55  void SetRcvKernelSize(const int value) override;
56  int GetRcvKernelSize() const override;
57 
58  unsigned long GetBytesTx() const override;
59  unsigned long GetBytesRx() const override;
60  unsigned long GetMessagesTx() const override;
61  unsigned long GetMessagesRx() const override;
62 
63  static int GetConstant(const std::string& constant);
64 
65  ~FairMQSocketSHM() override;
66 
67  private:
68  void* fSocket;
69  fair::mq::shmem::Manager& fManager;
70  std::string fId;
71  std::atomic<unsigned long> fBytesTx;
72  std::atomic<unsigned long> fBytesRx;
73  std::atomic<unsigned long> fMessagesTx;
74  std::atomic<unsigned long> fMessagesRx;
75 
76  static std::atomic<bool> fInterrupted;
77 
78  int fSndTimeout;
79  int fRcvTimeout;
80 };
81 
82 #endif /* FAIRMQSOCKETSHM_H_ */
Definition: Manager.h:38
Definition: FairMQTransportFactory.h:28
Definition: FairMQSocket.h:19
Definition: FairMQSocketSHM.h:20

privacy