FairMQ  1.4.14
C++ Message Queuing Library and Framework
FairMQSocketNN.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 FAIRMQSOCKETNN_H_
10 #define FAIRMQSOCKETNN_H_
11 
12 #include <vector>
13 #include <atomic>
14 
15 #include "FairMQSocket.h"
16 #include "FairMQMessage.h"
18 
19 class FairMQSocketNN final : public FairMQSocket
20 {
21  public:
22  FairMQSocketNN(const std::string& type, const std::string& name, const std::string& id = "", FairMQTransportFactory* fac = nullptr);
23  FairMQSocketNN(const FairMQSocketNN&) = delete;
24  FairMQSocketNN operator=(const FairMQSocketNN&) = delete;
25 
26  std::string GetId() const override { return fId; }
27 
28  bool Bind(const std::string& address) override;
29  bool Connect(const std::string& address) override;
30 
31  int Send(FairMQMessagePtr& msg, const int timeout = -1) override;
32  int Receive(FairMQMessagePtr& msg, const int timeout = -1) override;
33  int64_t Send(std::vector<std::unique_ptr<FairMQMessage>>& msgVec, const int timeout = -1) override;
34  int64_t Receive(std::vector<std::unique_ptr<FairMQMessage>>& msgVec, const int timeout = -1) override;
35 
36  int GetSocket() const;
37 
38  void Close() override;
39 
40  static void Interrupt();
41  static void Resume();
42 
43  void SetOption(const std::string& option, const void* value, size_t valueSize) override;
44  void GetOption(const std::string& option, void* value, size_t* valueSize) override;
45 
46  void SetLinger(const int value) override;
47  int GetLinger() const override;
48  void SetSndBufSize(const int value) override;
49  int GetSndBufSize() const override;
50  void SetRcvBufSize(const int value) override;
51  int GetRcvBufSize() const override;
52  void SetSndKernelSize(const int value) override;
53  int GetSndKernelSize() const override;
54  void SetRcvKernelSize(const int value) override;
55  int GetRcvKernelSize() const override;
56 
57  unsigned long GetBytesTx() const override;
58  unsigned long GetBytesRx() const override;
59  unsigned long GetMessagesTx() const override;
60  unsigned long GetMessagesRx() const override;
61 
62  static int GetConstant(const std::string& constant);
63 
64  ~FairMQSocketNN() override;
65 
66  private:
67  int fSocket;
68  std::string fId;
69  std::atomic<unsigned long> fBytesTx;
70  std::atomic<unsigned long> fBytesRx;
71  std::atomic<unsigned long> fMessagesTx;
72  std::atomic<unsigned long> fMessagesRx;
73 
74  static std::atomic<bool> fInterrupted;
75 
76  int fSndTimeout;
77  int fRcvTimeout;
78  int fLinger;
79 };
80 
81 #endif /* FAIRMQSOCKETNN_H_ */
Definition: FairMQTransportFactory.h:30
Definition: FairMQSocket.h:19
Definition: FairMQSocketNN.h:19

privacy