5 #include <Poco/Event.h>
6 #include <Poco/Mutex.h>
7 #include <Poco/SharedPtr.h>
9 #include "core/Exporter.h"
10 #include "exporters/QueuingStrategy.h"
11 #include "model/SensorData.h"
12 #include "util/Loggable.h"
47 typedef Poco::SharedPtr<QueuingExporter> Ptr;
58 void setStrategy(
const QueuingStrategy::Ptr strategy);
103 std::vector<SensorData> &data,
105 const Poco::Timespan &timeout);
124 bool shouldSave()
const;
125 size_t queueSize()
const;
127 bool waitNotEmpty(
const Poco::Timespan &timeout);
175 std::vector<SensorData> &data,
180 size_t mixFromBackup(
181 size_t requiredCount,
182 size_t queueDataCount,
183 size_t backupPriority,
186 void updateRemaindersAfterPeek(
188 size_t requiredToPeek,
189 double potentialRemainder);
191 size_t mixFromQueue(
size_t toAcquire,
size_t queueDataCount);
193 void saveQueue(
size_t skipFirst);
194 void doSaveQueue(
size_t skipFirst);
197 mutable Poco::Mutex m_queueMutex;
199 QueuingStrategy::Ptr m_strategy;
201 Poco::Event m_notEmpty;
203 uint32_t m_backupPriority;
204 size_t m_saveThreshold;
205 Poco::Timespan m_saveTimeout;
207 size_t m_acquiredDataCount;
208 size_t m_peekedDataCount;
209 Poco::Timestamp m_lastExport;
210 std::deque<SensorData> m_queue;
213 double m_mixRemainder;
214 double m_previousMixRemainder;
void reset()
Definition: QueuingExporter.cpp:230
Definition: SensorData.h:20
void setStrategyPriority(const int percent)
Definition: QueuingExporter.cpp:51
Definition: Exporter.h:11
bool empty() const
Definition: QueuingExporter.cpp:59
Implements Exporter interface and provides SensorData prevents SensorData loss.
Definition: QueuingExporter.h:45
void ack()
Definition: QueuingExporter.cpp:213
void acquire(std::vector< SensorData > &data, size_t count, const Poco::Timespan &timeout)
Definition: QueuingExporter.cpp:125
bool ship(const SensorData &data) override
Definition: QueuingExporter.cpp:107
void setSaveThreshold(const int dataCount)
Definition: QueuingExporter.cpp:35
Definition: Loggable.h:19
void setSaveTimeout(const Poco::Timespan &timeout)
Definition: QueuingExporter.cpp:43