BloombergLP::bdlcc::FixedQueueIndexManager::reservePopIndexForClear

Reserve a pop index for clearing cells up to a push reservation.

Synopsis

Declared in <bdlcc_fixedqueueindexmanager.h>

int
reservePopIndexForClear(
    unsigned int* disposedGeneration,
    unsigned int* disposedIndex,
    unsigned int endGeneration,
    unsigned int endIndex);

Description

If the next available index from which an element can be popped is before the specified endGeneration and endIndex then reserve that index for popping and load the specified disposedGeneration and disposedIndex with the generation and index of the reserved cell; otherwise this operation has no effect. Return 0 if an index was successfully reserved, and a non-zero value if the current pop index is at endIndex and endGeneration. The behavior is undefined unless endGeneration and endIndex refer to a cell that has been acquired for writing. Note that this operation is used to facilitate removing all the elements in a circular buffer if an exception is thrown between reserving an index for pushing, and committing that index -- the intended usage is to call reservePopIndexForClear and then commitPopIndex, emptying all the cells up to the index that was reserved for writing, and then call abortPushIndexReservation on the reserved index.

Return Value

0 if an index was reserved, non-zero if at the end cell

Parameters

NameDescription
disposedGenerationreceives the generation of the reserved cell
disposedIndexreceives the index of the reserved cell
endGenerationgeneration of the push-reserved end cell
endIndexindex of the push-reserved end cell