FairMQ  1.4.14
C++ Message Queuing Library and Framework
FairMQSocketZMQ.h
1 /********************************************************************************
2  * Copyright (C) 2014-2018 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 
9 #ifndef FAIRMQSOCKETZMQ_H_
10 #define FAIRMQSOCKETZMQ_H_
11 
12 #include <atomic>
13 
14 #include <memory> // unique_ptr
15 
16 #include "FairMQSocket.h"
17 #include "FairMQMessage.h"
19 
20 class FairMQSocketZMQ final : public FairMQSocket
21 {
22  public:
23  FairMQSocketZMQ(const std::string& type, const std::string& name, const std::string& id = "", void* context = nullptr, FairMQTransportFactory* factory = nullptr);
24  FairMQSocketZMQ(const FairMQSocketZMQ&) = delete;
25  FairMQSocketZMQ operator=(const FairMQSocketZMQ&) = delete;
26 
27  std::string GetId() const 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  ~FairMQSocketZMQ() override;
66 
67  private:
68  void* fSocket;
69  std::string fId;
70  std::atomic<unsigned long> fBytesTx;
71  std::atomic<unsigned long> fBytesRx;
72  std::atomic<unsigned long> fMessagesTx;
73  std::atomic<unsigned long> fMessagesRx;
74 
75  static std::atomic<bool> fInterrupted;
76 
77  int fSndTimeout;
78  int fRcvTimeout;
79 };
80 
81 #endif /* FAIRMQSOCKETZMQ_H_ */
Definition: FairMQSocketZMQ.h:20
Definition: FairMQTransportFactory.h:30
Definition: FairMQSocket.h:19

privacy