Go to the documentation of this file.
5 #ifndef _CIRCULAR_BFR_HPP_
6 #define _CIRCULAR_BFR_HPP_ "$Id: circular_bfr.hpp 454 2020-07-23 20:22:23Z geoff $"
28 #define DEFAULT_CIRCULAR_BFR_MAGIC_NUMBER "CIRCBFR"
31 #define DEFAULT_FIXED_BFR_MAGIC_NUMBER "FIXDBFR"
57 void initialize(
const char *component,
const char *magic,
80 void initialize(
const char *component,
const char *magic,
121 #if __SIZEOF_POINTER__ == 8
123 #define SHARED_BUFFER_OFFSET_SIZE 4
126 #define SHARED_BUFFER_OFFSET_SIZE 4
130 #if __SIZEOF_POINTER__ == 8
166 #pragma GCC diagnostic push
167 #pragma GCC diagnostic ignored "-Wsuggest-final-types"
204 BufferRegion(
unsigned char *ptr,
size_t len,
size_t blk_size,
225 void replaceRegion(
unsigned char *ptr,
size_t len,
size_t blk_size,
257 #pragma GCC diagnostic push
258 #pragma GCC diagnostic ignored "-Wsuggest-final-methods"
286 #pragma GCC diagnostic pop
336 const char *component=
"",
341 #pragma GCC diagnostic push
342 #pragma GCC diagnostic ignored "-Wsuggest-final-methods"
344 #pragma GCC diagnostic pop
361 const char *component=
"",
377 #pragma GCC diagnostic pop
Impose a fixed-size buffer on a BufferRegion.
Definition: circular_bfr.hpp:356
virtual SharedBufferAllocRecord * allocateBlock(size_t len) VIRTUAL_OVERRIDE
Definition: circular_bfr.cpp:324
virtual BufferRegion_Overhead_t getBlockOverhead() const VIRTUAL_OVERRIDE
Interface to return the per-block overhead associated with an allocator.
Definition: circular_bfr.hpp:350
bool sharedBufferSegmentIsInNativeByteOrder(const void *segment)
Indicates if segment uses native byte order.
Definition: circular_bfr.hpp:90
#define GET_VAL(fieldName, ptr32, ptr64, is64, isNative)
Definition: circular_bfr.cpp:32
virtual SharedBufferAllocRecord * getFreeListHead()
Return first free allocation record.
Definition: circular_bfr.cpp:213
virtual void returnBlock(SharedBufferAllocRecord *record) VIRTUAL_OVERRIDE
Definition: circular_bfr.cpp:513
uint32_t offset_block
Definition: circular_bfr.hpp:105
@ NOT_OWNER
indicates region is not owned by this BufferRegion
Definition: circular_bfr.hpp:180
virtual BufferRegion_Overhead_t getBlockOverhead() const =0
Interface to return the per-block overhead associated with an allocator.
#define stdout
Definition: tmp.o.cpp:3117
Allocation record for chains in a 32-bit shared memory buffer.
Definition: circular_bfr.hpp:103
virtual unsigned char * blockAddress(const SharedBufferAllocRecord *record)
Definition: circular_bfr.hpp:282
virtual BufferRegion_Overhead_t getBlockOverhead() const VIRTUAL_OVERRIDE
Interface to return the per-block overhead associated with an allocator.
Definition: circular_bfr.hpp:372
virtual SharedBufferAllocRecord * getActiveListHead()
Return first active allocation record.
Definition: circular_bfr.cpp:196
uint64_t usedLen
Definition: circular_bfr.hpp:116
OwnershipState ownership
Definition: circular_bfr.hpp:191
#define stderr
Definition: tmp.o.cpp:3115
@ OWN_BLOCK
indicates region is owned by the BufferRegion and should be recovered when deleted.
Definition: circular_bfr.hpp:181
static int32_t TOTAL_allocation_wait_spins
Definition: circular_bfr.hpp:358
uint32_t offset_allocRecord
Definition: circular_bfr.hpp:104
SharedBufferRegionHeader_32 SharedBufferRegionHeader
Default SharedBufferRegionHeader.
Definition: circular_bfr.hpp:125
virtual SharedBufferAllocRecord * allocateBlock(size_t len) VIRTUAL_OVERRIDE
Definition: circular_bfr.cpp:681
static int32_t TOTAL_return_wait_spins
Definition: circular_bfr.hpp:333
#define VIRTUAL_OVERRIDE
Generates override if the compiler supports it.
Definition: compiler_hints.h:435
uint64_t offset_allocRecord
Definition: circular_bfr.hpp:113
uint64_t blockLen
Definition: circular_bfr.hpp:115
size_t availableBlocks
Definition: circular_bfr.hpp:190
unsigned char * getBufferBase() const OME_ALWAYS_INLINE
Return the address of the buffer region.
Definition: circular_bfr.hpp:253
@ OWN_MAP
indicates region is a memory map owned by the BufferRegion and should be unmapped when deleted.
Definition: circular_bfr.hpp:182
uint64_t offset_block
Definition: circular_bfr.hpp:114
#define OME_YIELD_THREAD()
Macro for platform-specific yield of thread's time slice.
Definition: compiler_hints.h:547
size_t getRegionLength() const OME_ALWAYS_INLINE
Return the number of bytes in the region.
Definition: circular_bfr.hpp:243
const char * getFileType(const char *fileName)
Definition: catSym.c:161
virtual SharedBufferAllocRecord * traverseNextBlock(SharedBufferAllocRecord *record)
Traverse to next allocation record on current chain.
Definition: circular_bfr.cpp:233
unsigned char * region
Definition: circular_bfr.hpp:187
#define MAX_MODULES
Definition: catSym.c:19
OwnershipState
Definition: circular_bfr.hpp:179
#define OME_PREFETCH(addr, rw, locality)
Macro to request prefetch.
Definition: compiler_hints.h:362
uint64_t offset_nextInChain
Definition: circular_bfr.hpp:117
~CircularBufferManager()
Definition: circular_bfr.hpp:343
CircularBufferManager(unsigned char *ptr, size_t len, size_t blk_size, const char *component="", const char *magicNumber=DEFAULT_CIRCULAR_BFR_MAGIC_NUMBER)
Definition: circular_bfr.cpp:159
OwnershipState getOwnership() const
Return the administrative ownership state of the region.
Definition: circular_bfr.hpp:238
#define EOF
Definition: tmp.o.cpp:135
static int32_t TOTAL_allocation_wait_spins
Definition: circular_bfr.hpp:332
const char srcID[]
Definition: catSym.c:17
size_t regionLength
Definition: circular_bfr.hpp:188
void waitForBufferAllocRecordToBeReady(SharedBufferAllocRecord *rec)
Verify record is prepared and, if needed, wait until it is prepared.
Definition: circular_wait.hpp:16
#define MAX_LINE_LEN
Definition: catSym.c:15
DEFINE_DID_COMPARE_AND_SWAP_TYPE(size_t, size_t)
virtual ~BufferRegion()
Destructor for a BufferRegion.
Definition: circular_bfr.cpp:121
FixedBufferManager(unsigned char *ptr, size_t len, size_t blk_size, const char *component="", const char *magicNumber=DEFAULT_FIXED_BFR_MAGIC_NUMBER)
Definition: circular_bfr.cpp:654
uint32_t OFFSET_T
Definition: circular_bfr.cpp:21
#define OME_EXPECT_TRUE(expr)
Annotation macro for conditional expression expected to be true.
Definition: compiler_hints.h:541
virtual SharedBufferAllocRecord * allocateBlock(size_t len)=0
virtual void returnBlock(SharedBufferAllocRecord *record)=0
uint32_t offset_nextInChain
Definition: circular_bfr.hpp:108
DEFINE_COMPARE_AND_SWAP_TYPE(size_t, size_t)
size_t getBlockSize() const OME_ALWAYS_INLINE
Return the block size set for the region.
Definition: circular_bfr.hpp:248
BufferRegion(unsigned char *ptr, size_t len, size_t blk_size, OwnershipState ownedBy=NOT_OWNER)
Definition: circular_bfr.cpp:106
int display(OMEthread *thread, OMEtype &result, const OMEtype &argSet)
Definition: OILdebug.cpp:112
bool sharedBufferSegmentSizeIs64bit(const void *segment)
Indicates if segment uses 64-bit offsets.
Definition: circular_bfr.hpp:97
@ OWN_RECORD
Definition: circular_bfr.hpp:183
size_t blockSize
Definition: circular_bfr.hpp:189
const char srcID[] OME_USED
Definition: tick_time.cpp:24
~FixedBufferManager()
Definition: circular_bfr.cpp:676
uint_fast8_t BufferRegion_Overhead_t
Definition: circular_bfr.hpp:185
Impose a circular buffer on a BufferRegion.
Definition: circular_bfr.hpp:330
Compiler-specific macros to provide performance-related hints.
#define OME_EXPECT_FALSE(expr)
Annotation macro for conditional expression expected to be false.
Definition: compiler_hints.h:540
uint32_t usedLen
Definition: circular_bfr.hpp:107
#define OME_ALWAYS_INLINE
Tell the compiler to alway inline a function, regardless of optimization level.
Definition: compiler_hints.h:364
#define DEFAULT_CIRCULAR_BFR_MAGIC_NUMBER
Magic number to identify a shared memory circular buffer.
Definition: circular_bfr.hpp:28
uint32_t blockLen
Definition: circular_bfr.hpp:106
char * malloc(unsigned int bytes)
Definition: test_malloc.c:441
void setOwnership(OwnershipState newOwnership)
Change administrative ownership of region.
Definition: circular_bfr.hpp:232
#define DID_COMPARE_SWAP_OFFSET(ptr, v1, v2)
Definition: circular_bfr.cpp:22
void replaceRegion(unsigned char *ptr, size_t len, size_t blk_size, OwnershipState ownedBy=NOT_OWNER)
Reconstruct the buffer using a new region.
Definition: circular_bfr.cpp:142
int checkLists(int displayFlag)
Debug routine used to verify integrity of block lists.
Definition: circular_bfr.cpp:249
virtual void returnBlock(SharedBufferAllocRecord *record) VIRTUAL_OVERRIDE
Definition: circular_bfr.cpp:811
SharedBufferAllocRecord_32 SharedBufferAllocRecord
Default SharedBufferAllocRecord.
Definition: circular_bfr.hpp:133
Interface to a buffer region. This is an abstract class.
Definition: circular_bfr.hpp:177
uint32_t SharedBuffer_Offset_t
Definition: circular_bfr.hpp:39
#define GET_VAL32(fieldName, ptr32, ptr64, is64, isNative)
Definition: circular_bfr.cpp:30
#define DEFAULT_FIXED_BFR_MAGIC_NUMBER
Magic number to identify a fixed-size memory buffer.
Definition: circular_bfr.hpp:31
int main(int argc, const char *argv[])
Definition: catSym.c:209
Allocation record for chains in a 64-bit shared memory buffer.
Definition: circular_bfr.hpp:112