HIPO  4.3.0
High Performance Output data format for experimental physics
hipo::readerstream Class Reference

Thread-safe reader for parallel event processing. More...

#include <reader.h>

Public Member Functions

 readerstream ()
 
virtual ~readerstream ()
 
void open (const char *input)
 Open a HIPO file for multi-threaded reading. More...
 
void setLimit (long limit)
 Set a limit on the number of events to process. More...
 
void run (std::function< int(int)> &&function, int nthreads)
 Launch worker threads that execute the given function. More...
 
hipo::readerreader ()
 
hipo::dictionarydictionary ()
 
void pull (hipo::record &record, int index)
 Thread-safe loading of a record by index. More...
 
void pull (std::vector< hipo::event > &events)
 Thread-safe batch pull: resets each event in the vector, reads next events, and refills. More...
 

Detailed Description

Thread-safe reader for parallel event processing.

Wraps a hipo::reader with a mutex to allow multiple threads to pull events concurrently. Events are distributed in batches via the pull() method.

Definition at line 403 of file reader.h.

Constructor & Destructor Documentation

◆ readerstream()

hipo::readerstream::readerstream ( )
inline

Definition at line 415 of file reader.h.

◆ ~readerstream()

virtual hipo::readerstream::~readerstream ( )
inlinevirtual

Definition at line 417 of file reader.h.

Member Function Documentation

◆ dictionary()

hipo::dictionary& hipo::readerstream::dictionary ( )
inline
Returns
Reference to the dictionary read from the file.

Definition at line 450 of file reader.h.

◆ open()

void hipo::readerstream::open ( const char *  input)
inline

Open a HIPO file for multi-threaded reading.

Parameters
inputPath to the HIPO file

Definition at line 421 of file reader.h.

◆ pull() [1/2]

void hipo::readerstream::pull ( hipo::record record,
int  index 
)
inline

Thread-safe loading of a record by index.

Parameters
recordOutput record object
indexRecord index

Definition at line 455 of file reader.h.

◆ pull() [2/2]

void hipo::readerstream::pull ( std::vector< hipo::event > &  events)
inline

Thread-safe batch pull: resets each event in the vector, reads next events, and refills.

Parameters
eventsVector of events to refill from the file

Definition at line 462 of file reader.h.

◆ reader()

hipo::reader& hipo::readerstream::reader ( )
inline
Returns
Reference to the underlying reader.

Definition at line 448 of file reader.h.

◆ run()

void hipo::readerstream::run ( std::function< int(int)> &&  function,
int  nthreads 
)
inline

Launch worker threads that execute the given function.

Parameters
functionWorker function taking a thread ID and returning an int
nthreadsNumber of threads to create

Definition at line 437 of file reader.h.

◆ setLimit()

void hipo::readerstream::setLimit ( long  limit)
inline

Set a limit on the number of events to process.

Parameters
limitMaximum events (-1 for unlimited)

Definition at line 430 of file reader.h.


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