Producer.h
968 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Producer.h
*
* Created on: 15 gru 2018
* Author: mariuszo
*/
#ifndef PRODUCER_H_
#define PRODUCER_H_
#include <string>
#include <thread>
#include "SubsystemBase.h"
#include "MemoryManager.h"
#include "Synchronizer.h"
/*
#include <unistd.h>
*/
class Producer : public SubsystemBase {
MemoryManager<access_type::access_master> m_memoryManagerData;
Synchronizer<access_type::access_master> m_synchronizerData;
std::thread m_bufferReleaseThread;
sem_t m_bufferReleaseMonitorStarted;
public:
Producer(const std::string& name);
virtual ~Producer();
void create(const size_t& bufferSize, const size_t& dataSlotsRingBufferSize);
void init();
void done();
void allocateDataBlock(DataBlock& dataBlock, const size_t size, const uint64_t& timeoutns=UINT64_MAX);
void releaseDataBlock(const DataBlock& data);
bool commit(DataBlock& dataBlock, const uint64_t& timeoutns=UINT64_MAX);
private:
void bufferReleaseTask();
};
#endif /* PRODUCER_H_ */