Threads safe socket rate stats

This commit is contained in:
Alexey Rybalchenko 2016-05-12 09:13:57 +02:00 committed by Mohammad Al-Turany
parent 3353e214a7
commit 31456e71ff
2 changed files with 11 additions and 8 deletions

View File

@ -16,6 +16,7 @@
#define FAIRMQSOCKETNN_H_ #define FAIRMQSOCKETNN_H_
#include <vector> #include <vector>
#include <atomic>
#include "FairMQSocket.h" #include "FairMQSocket.h"
@ -64,10 +65,10 @@ class FairMQSocketNN : public FairMQSocket
private: private:
int fSocket; int fSocket;
std::string fId; std::string fId;
unsigned long fBytesTx; std::atomic<unsigned long> fBytesTx;
unsigned long fBytesRx; std::atomic<unsigned long> fBytesRx;
unsigned long fMessagesTx; std::atomic<unsigned long> fMessagesTx;
unsigned long fMessagesRx; std::atomic<unsigned long> fMessagesRx;
}; };
#endif /* FAIRMQSOCKETNN_H_ */ #endif /* FAIRMQSOCKETNN_H_ */

View File

@ -15,6 +15,8 @@
#ifndef FAIRMQSOCKETZMQ_H_ #ifndef FAIRMQSOCKETZMQ_H_
#define FAIRMQSOCKETZMQ_H_ #define FAIRMQSOCKETZMQ_H_
#include <atomic>
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include "FairMQSocket.h" #include "FairMQSocket.h"
@ -65,10 +67,10 @@ class FairMQSocketZMQ : public FairMQSocket
private: private:
void* fSocket; void* fSocket;
std::string fId; std::string fId;
unsigned long fBytesTx; std::atomic<unsigned long> fBytesTx;
unsigned long fBytesRx; std::atomic<unsigned long> fBytesRx;
unsigned long fMessagesTx; std::atomic<unsigned long> fMessagesTx;
unsigned long fMessagesRx; std::atomic<unsigned long> fMessagesRx;
static boost::shared_ptr<FairMQContextZMQ> fContext; static boost::shared_ptr<FairMQContextZMQ> fContext;
}; };