Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HDEVIOWriter Class Reference

#include <HDEVIOWriter.h>

Public Types

enum  EVIOSinkType { kNoSink, kFileSink, kETSink }
 

Public Member Functions

 HDEVIOWriter (string sink_name)
 
virtual ~HDEVIOWriter ()
 
void * HDEVIOOutputThread (void)
 
vector< uint32_t > * GetBufferFromPool (void)
 
void ReturnBufferToPool (vector< uint32_t > *buff)
 
void AddBufferToOutput (vector< uint32_t > *buff)
 
void FlushOutput (uint32_t Nwords, deque< vector< uint32_t > * > &my_output_deque)
 
void Quit (void)
 

Protected Member Functions

void ConnectToET (string sink_name)
 

Protected Attributes

bool quit
 
uint32_t MAX_OUTPUT_QUEUE_SIZE
 
uint32_t MAX_OUTPUT_BUFFER_SIZE
 
uint32_t MAX_HOLD_TIME
 
uint32_t NEVENTS_PER_BLOCK
 
bool DEBUG_FILES
 
deque< vector< uint32_t > * > output_deque
 
pthread_mutex_t output_deque_mutex
 
pthread_mutex_t buff_pool_mutex
 
vector< vector< uint32_t > * > buff_pool
 
vector< uint32_t > output_block
 
ofstream * evioout
 
ofstream * ofs_debug_output
 
EVIOSinkType sink_type
 
uint32_t events_written_to_output
 
uint32_t blocks_written_to_output
 

Detailed Description

Definition at line 30 of file HDEVIOWriter.h.

Member Enumeration Documentation

Enumerator
kNoSink 
kFileSink 
kETSink 

Definition at line 33 of file HDEVIOWriter.h.

Constructor & Destructor Documentation

HDEVIOWriter::HDEVIOWriter ( string  sink_name)

Definition at line 21 of file HDEVIOWriter.cc.

References e.

HDEVIOWriter::~HDEVIOWriter ( )
virtual

Definition at line 108 of file HDEVIOWriter.cc.

Member Function Documentation

void HDEVIOWriter::AddBufferToOutput ( vector< uint32_t > *  buff)

Add the given buffer to the list of buffers to be written to the output. This will check that the size of the output list has not grown too large (default is 200 events) and if so, it will block until the list emptys out a bit. This Should apply back-pressure by having all processing threads stop here until either the output catches up, or we are told to quit.

Definition at line 551 of file HDEVIOWriter.cc.

Referenced by DEventWriterEVIO::Write_EVIOBuffer(), and DEventWriterEVIO::Write_EVIOEvent().

void HDEVIOWriter::ConnectToET ( string  sink_name)
protected

Definition at line 141 of file HDEVIOWriter.cc.

References str, and string.

void HDEVIOWriter::FlushOutput ( uint32_t  Nwords,
deque< vector< uint32_t > * > &  my_output_deque 
)

Write the given buffer to the output channel (either file or ET). This is called from the dedicated output thread and should not be called from anywhere else. If it is unable to write the buffer to the output for any reason, then a JException is thrown. The size of the buffer is taken from the first word which is assumed to be the number of 32-bit words in the buffer, not counting the leading length word. Thus, a total of (buff[0]+1)*4 bytes is taken as the total size of the buffer.

Definition at line 379 of file HDEVIOWriter.cc.

References sprintf(), str, swap_bank_out(), and swap_block_out().

vector< uint32_t > * HDEVIOWriter::GetBufferFromPool ( void  )

Get a buffer from the buffer pool in a thread safe way. This actually removes the buffer from the pool completely so the caller gains ownership of the buffer.

Definition at line 514 of file HDEVIOWriter.cc.

Referenced by DEventWriterEVIO::Write_EVIOEvent().

void * HDEVIOWriter::HDEVIOOutputThread ( void  )

This is run in a dedicated thread and is responsible for writing events to the ouput, one at a time. EVIO buffers, one per event, are created by the processing threads using the WriteEvent method of this class. It stores them in a queue which this thread monitors, writing out events as it finds them. If the queue is empty, this thread will sleep until either one becomes available, or the thread is told to Quit.

Definition at line 278 of file HDEVIOWriter.cc.

References japp.

void HDEVIOWriter::Quit ( void  )

Definition at line 586 of file HDEVIOWriter.cc.

Referenced by DEventWriterEVIO::~DEventWriterEVIO().

void HDEVIOWriter::ReturnBufferToPool ( vector< uint32_t > *  buff)

Return a buffer to the pool.

Definition at line 539 of file HDEVIOWriter.cc.

Member Data Documentation

uint32_t HDEVIOWriter::blocks_written_to_output
protected

Definition at line 77 of file HDEVIOWriter.h.

vector< vector<uint32_t>* > HDEVIOWriter::buff_pool
protected

Definition at line 68 of file HDEVIOWriter.h.

pthread_mutex_t HDEVIOWriter::buff_pool_mutex
protected

Definition at line 67 of file HDEVIOWriter.h.

bool HDEVIOWriter::DEBUG_FILES
protected

Definition at line 61 of file HDEVIOWriter.h.

uint32_t HDEVIOWriter::events_written_to_output
protected

Definition at line 76 of file HDEVIOWriter.h.

ofstream* HDEVIOWriter::evioout
protected

Definition at line 73 of file HDEVIOWriter.h.

uint32_t HDEVIOWriter::MAX_HOLD_TIME
protected

Definition at line 59 of file HDEVIOWriter.h.

uint32_t HDEVIOWriter::MAX_OUTPUT_BUFFER_SIZE
protected

Definition at line 58 of file HDEVIOWriter.h.

uint32_t HDEVIOWriter::MAX_OUTPUT_QUEUE_SIZE
protected

Definition at line 57 of file HDEVIOWriter.h.

uint32_t HDEVIOWriter::NEVENTS_PER_BLOCK
protected

Definition at line 60 of file HDEVIOWriter.h.

ofstream* HDEVIOWriter::ofs_debug_output
protected

Definition at line 74 of file HDEVIOWriter.h.

vector<uint32_t> HDEVIOWriter::output_block
protected

Definition at line 71 of file HDEVIOWriter.h.

deque< vector<uint32_t>* > HDEVIOWriter::output_deque
protected

Definition at line 63 of file HDEVIOWriter.h.

pthread_mutex_t HDEVIOWriter::output_deque_mutex
protected

Definition at line 64 of file HDEVIOWriter.h.

bool HDEVIOWriter::quit
protected

Definition at line 54 of file HDEVIOWriter.h.

EVIOSinkType HDEVIOWriter::sink_type
protected

Definition at line 75 of file HDEVIOWriter.h.


The documentation for this class was generated from the following files: