11 #ifndef EVIO_6_0_RECORDCOMPRESSOR_H
12 #define EVIO_6_0_RECORDCOMPRESSOR_H
28 #include "Disruptor/Util.h"
29 #include <boost/thread.hpp>
49 uint32_t threadNumber;
53 std::shared_ptr<RecordSupply> supply;
66 std::shared_ptr<RecordSupply> & recordSupply) :
68 compressionType(type),
69 supply(recordSupply) {
73 threadNumber(obj.threadNumber),
74 compressionType(obj.compressionType),
75 supply(std::move(obj.supply)),
76 thd(std::move(obj.thd)) {
81 threadNumber = obj.threadNumber;
82 compressionType = obj.compressionType;
83 supply = std::move(obj.supply);
84 thd = std::move(obj.thd);
91 if (thd.try_join_for(boost::chrono::milliseconds(500))) {
92 std::cout <<
"RecordCompressor thread did not quit after 1/2 sec" << std::endl;
98 thd = boost::thread([
this]() {this->
run();});
121 int64_t seqNumber = (int64_t)threadNumber - 1;
122 supply->release(threadNumber, seqNumber);
127 auto item = supply->getToCompress(threadNumber);
131 boost::this_thread::disable_interruption d1;
134 std::shared_ptr<RecordOutput> & record = item->getRecord();
136 auto & header = record->getHeader();
137 header->setCompressionType(compressionType);
142 supply->releaseCompressor(item);
146 catch (boost::thread_interrupted & e) {
156 #endif //EVIO_6_0_RECORDCOMPRESSOR_H
void run()
Method to run in the thread.
Definition: RecordCompressor.h:110
CompressionType
Enum of supported data compression types.
Definition: Compressor.h:65
Class used to create a thread which takes data-filled records from a RingBuffer-backed RecordSupply...
Definition: RecordCompressor.h:44
~RecordCompressor()
Definition: RecordCompressor.h:89
RecordCompressor(uint32_t thdNum, Compressor::CompressionType &type, std::shared_ptr< RecordSupply > &recordSupply)
Constructor.
Definition: RecordCompressor.h:65
RecordCompressor(RecordCompressor &&obj) noexcept
Definition: RecordCompressor.h:72
void startThread()
Create and start a thread to execute the run() method of this class.
Definition: RecordCompressor.h:97
RecordCompressor & operator=(RecordCompressor &&obj) noexcept
Definition: RecordCompressor.h:79
void stopThread()
Stop the thread.
Definition: RecordCompressor.h:102