mirror of
https://github.com/DaKerboul/perun.git
synced 2026-08-09 23:55:40 +02:00
renamed to pierog, extracted socket and file writers
This commit is contained in:
40
03_Perun_Lua_Wrapper/pierog/src/DataDistributor.h
Normal file
40
03_Perun_Lua_Wrapper/pierog/src/DataDistributor.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef PARENT_DATADISTRIBUTOR_H
|
||||
#define PARENT_DATADISTRIBUTOR_H
|
||||
|
||||
#include <string>
|
||||
#include <queue>
|
||||
#include "SocketOutput.h"
|
||||
#include "RotatingFileOutput.h"
|
||||
|
||||
class DataDistributor {
|
||||
public:
|
||||
DataDistributor(std::string logPath,
|
||||
std::string host,
|
||||
int port);
|
||||
|
||||
virtual ~DataDistributor();
|
||||
|
||||
void enqueueForSending(std::string* payload);
|
||||
void markNewRecording();
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
||||
int isConnected();
|
||||
|
||||
private:
|
||||
std::atomic<boolean> shouldRun = true;
|
||||
std::atomic<boolean> running = false;
|
||||
std::atomic<boolean> everSentViaSocket = false;
|
||||
std::deque<std::string*> dataBuffer;
|
||||
std::deque<std::string*> sendQueue;
|
||||
std::mutex lock;
|
||||
|
||||
std::chrono::time_point<std::chrono::system_clock> lastSent = std::chrono::system_clock::now();
|
||||
|
||||
SocketOutput* socketOutput;
|
||||
RotatingFileOutput* fileOutput;
|
||||
};
|
||||
|
||||
|
||||
#endif //PARENT_DATADISTRIBUTOR_H
|
||||
Reference in New Issue
Block a user