95 const auto startPos = (readPos + numReadable) & (size - 1);
111 const auto startPos = readPos;
115 readPos = (startPos +
maxToRead) & (size - 1);
122 int size = 0, readPos = 0, numReadable = 0;
Encapsulates the logic for a single-threaded FIFO.
SingleThreadedAbstractFifo(int sizeIn)
Creates a SingleThreadedAbstractFifo that can manage a buffer of the specified size.
SingleThreadedAbstractFifo()=default
Creates a SingleThreadedAbstractFifo with no size.
int getRemainingSpace() const
Returns the number of unused elements present in the buffer.
std::array< Range< int >, 2 > read(int num)
Returns two blocks in the buffer from which new items may be read.
int getSize() const
Returns the size of the managed buffer.
std::array< Range< int >, 2 > write(int num)
Returns two blocks in the buffer where new items may be written.
int getNumReadable() const
Returns the number of pending elements present in the buffer.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
constexpr bool isPowerOfTwo(IntegerType value)
Returns true if the specified integer is a power-of-two.