//============================================================================ // Name : TestCirculatBuffer.cpp // Author : Hovanes Egiyan // Version : // Copyright : Your copyright notice // Description : Hello World in C++, Ansi-style //============================================================================ #include #include #include #include #include #include #include #include #include #include #include "boost148/boost/circular_buffer.hpp" #include "boost148/boost/circular_buffer_fwd.hpp" #include "boost148/boost/circular_buffer/base.hpp" #include #include #include #include #include #include // for auto_cpu_timer #include "../BufferFiller.hh" #include "../BufferReader.hh" #include "../CircularBufferMT.hh" #include "../ReadoutBuffer.hh" using namespace std; using namespace VETROC; const unsigned dmaLengthInWords = 8640; //const unsigned dmaLengthInWords = 8; const unsigned circularBufferLength = 10000; typedef VETROC::ReadoutBuffer BufferType; void testCircularMTBuffer() { cout << "Starting CircularMT test " << endl; uint32_t dmaArray[dmaLengthInWords]; memset( dmaArray, -1, dmaLengthInWords * sizeof(uint32_t) ); // for ( unsigned iElm = 0; iElm < dmaLengthInWords; iElm++ ) { // cout << "Element " << iElm << " in DMA is " << dmaArray[iElm] << endl; // } // // Start of timing. // boost::timer::auto_cpu_timer progress; // typedef CircularBufferMT CircularBufferType ; CircularBufferType circularBuffer( circularBufferLength ); // Construct the threads. BufferFiller filler(&circularBuffer,dmaArray ); BufferReader reader(&circularBuffer); // Start the threads. boost::thread fill( &BufferFiller::keepFillingBuffer, &filler ); boost::thread read( &BufferReader::keepReadingBuffer, &reader ); // Wait for completion. fill.join(); read.join(); } int main() { // cout << "Testing Simple Circular Buffer" << endl; // testCicularBuffer(); // cout << "Testing Bounder Circular Buffer" << endl; // testBoundedBuffer(); cout << "Testing CircularMT buffer" << endl; testCircularMTBuffer(); return 0; }