Producer.h 968 Bytes
/*
 * 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_ */