BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
QueuingDistributor.h
1 #pragma once
2 
3 #include <Poco/AtomicCounter.h>
4 #include <Poco/Event.h>
5 #include <Poco/Mutex.h>
6 #include <Poco/SharedPtr.h>
7 #include <Poco/Timespan.h>
8 #include <Poco/Timestamp.h>
9 
10 #include "core/AbstractDistributor.h"
11 #include "core/ExporterQueue.h"
12 #include "loop/StoppableRunnable.h"
13 #include "model/SensorData.h"
14 
15 namespace BeeeOn {
16 
18 public:
21 
22  void registerExporter(Poco::SharedPtr<Exporter> exporter) override;
23  void exportData(const SensorData &sensorData) override;
24 
25  void setQueueCapacity(int capacity);
26  void setQueueTreshold(int treshold);
27  void setQueueBatchSize(int batchSize);
28 
33  void setDeadTimeout(const Poco::Timespan &timeout);
34 
39  void setIdleTimeout(const Poco::Timespan &timeout);
40 
41  void run() override;
42  void stop() override;
43 
44 protected:
45  std::vector<ExporterQueue::Ptr> m_queues;
46  Poco::Event m_newData;
47  Poco::AtomicCounter m_stop;
48  Poco::Timespan m_deadTimeout;
49  Poco::Timespan m_idleTimeout;
50  int m_queueCapacity;
51  int m_batchSize;
52  int m_treshold;
53 };
54 
55 }
Definition: SensorData.h:20
Definition: AbstractDistributor.h:17
Definition: QueuingDistributor.h:17
void stop() override
Definition: QueuingDistributor.cpp:125
Definition: StoppableRunnable.h:8
void setDeadTimeout(const Poco::Timespan &timeout)
Definition: QueuingDistributor.cpp:68
void setIdleTimeout(const Poco::Timespan &timeout)
Definition: QueuingDistributor.cpp:76