NSCL DDAS
12.1-001
Support for XIA DDAS at FRIB
|
This class extends RawChannel to produce a raw channel that is zero-copied from a reference counted buffer that comes from a buffer arena. This is a key data structure in the zero-copy DDAS readout. More...
#include <ZeroCopyHit.h>
Public Member Functions | |
ZeroCopyHit () | |
Default constructor. More... | |
ZeroCopyHit (size_t nWords, void *pHitData, ReferenceCountedBuffer *pBuffer, BufferArena *pArena) | |
Construct from parameters. More... | |
ZeroCopyHit (const ZeroCopyHit &rhs) | |
Copy constructor. More... | |
ZeroCopyHit & | operator= (const ZeroCopyHit &rhs) |
Assignment operator. More... | |
virtual | ~ZeroCopyHit () |
Destructor. More... | |
void | setHit (size_t nWords, void *pHitData, ReferenceCountedBuffer *pBuffer, BufferArena *pArena) |
Sets a new hit. More... | |
void | freeHit () |
Free an existing hit. More... | |
![]() | |
RawChannel () | |
Default constructor. More... | |
RawChannel (size_t nWords) | |
Construct a channel for copy-in data. More... | |
RawChannel (size_t nWords, void *pZcopyData) | |
Constructor initialized with zero-copy hit data. More... | |
virtual | ~RawChannel () |
Destructor. More... | |
int | SetTime () |
Set the 48-bit timestamp data from the hit infomration. More... | |
int | SetTime (double nsPerTick, bool useExt=false) |
Set time time in ns. More... | |
int | SetLength () |
Set the event length from the data. More... | |
int | SetChannel () |
Set the channel value from the data. More... | |
int | Validate (int expecting) |
Determine if a channel has the correct amount of data. More... | |
void | setData (size_t nWords, void *pZCopyData) |
Set new data. More... | |
void | copyInData (size_t nWords, const void *pData) |
Copy in data. More... | |
RawChannel (const RawChannel &rhs) | |
Copy constructor. More... | |
RawChannel & | operator= (const RawChannel &rhs) |
Assignment operator. More... | |
Additional Inherited Members | |
![]() | |
static uint32_t | channelLength (void *pData) |
Extract the number of words in a hit. More... | |
static double | moduleCalibration (uint32_t moduleType) |
Returns the multiplier used to convert the module raw timestamp into nanoseconds. More... | |
![]() | |
uint32_t | s_moduleType |
Type of module this comes from. More... | |
double | s_time |
Extracted time, possibly calibrated. More... | |
int | s_chanid |
Channel within module. More... | |
bool | s_ownData |
True if we own s_data. More... | |
int | s_ownDataSize |
If we own data, how many uint32_t's. More... | |
int | s_channelLength |
Number of uint32_t in s_data. More... | |
uint32_t * | s_data |
Pointer to the hit data. More... | |
This class extends RawChannel to produce a raw channel that is zero-copied from a reference counted buffer that comes from a buffer arena. This is a key data structure in the zero-copy DDAS readout.
This acts like a RawChannel, but on destruction, if it is the last reference to the buffer, returns it to the arena from whence it came.
Copy construction and assignment are supported with appropriate semantics to handle proper reference counting.
I'm sure I'm hearing a pile of people ask me why not use std::shared_pointer – The answer is that I don't actually want the buffers to be destroyed as that involves expensive dynamic memory management, I want storage returned to a pre-allocated buffer arena from which it can be quickly re-gotten. Yeah I suppose I could use custom new/delete methods but that seems pretty painful and at least as error prone as this code.
DDASReadout::ZeroCopyHit::ZeroCopyHit | ( | ) |
Default constructor.
Creates a hit. The hit must be initialized with setHit before being accessed.
DDASReadout::ZeroCopyHit::ZeroCopyHit | ( | size_t | nWords, |
void * | pHitData, | ||
ReferenceCountedBuffer * | pBuffer, | ||
BufferArena * | pArena | ||
) |
Construct from parameters.
nWords | Number of uint32_t's in the hit. |
pHitData | Pointer to the hit data. |
pBuffer | Underlying reference counted buffer. |
pArena | Buffer arena to which the buffer is released when no longer referenced. |
Stores stuff away and increments the refrence count on the underlying buffer.
DDASReadout::ZeroCopyHit::ZeroCopyHit | ( | const ZeroCopyHit & | rhs | ) |
Copy constructor.
rhs | Reference ot ZeroCopyHit object to copy. |
Copy in the new hit and reference.
|
virtual |
Destructor.
Dereference.
void DDASReadout::ZeroCopyHit::freeHit | ( | ) |
Free an existing hit.
If this hit is associated with data, disassociates.
ZeroCopyHit & DDASReadout::ZeroCopyHit::operator= | ( | const ZeroCopyHit & | rhs | ) |
Assignment operator.
rhs | Reference to ZeroCopyHit object assigned to lhs. |
Dereference, copy in, reference.
void DDASReadout::ZeroCopyHit::setHit | ( | size_t | nWords, |
void * | pHitData, | ||
ReferenceCountedBuffer * | pBuffer, | ||
BufferArena * | pArena | ||
) |
Sets a new hit.
nWords | Number of words in the new hit. |
pHitData | Pointer to the hit data. |
pBuffer | Buffer from whence the hit data came. |
pArena | Arena to which the buffer is returned. |
If the hit is associated with a zero copy buffer, the reference is released first.