94 int getTotalSize()
const noexcept;
97 int getFreeSpace()
const noexcept;
100 int getNumReady()
const noexcept;
103 void reset() noexcept;
109 void setTotalSize (
int newSize) noexcept;
151 void prepareToWrite (
int numToWrite,
int& startIndex1,
int& blockSize1,
int& startIndex2,
int& blockSize2)
const noexcept;
156 void finishedWrite (
int numWritten) noexcept;
196 void prepareToRead (
int numWanted,
int& startIndex1,
int& blockSize1,
int& startIndex2,
int& blockSize2)
const noexcept;
201 void finishedRead (
int numRead) noexcept;
206 enum class ReadOrWrite
214 template <ReadOrWrite mode>
228 prepare (*fifo, num);
243 finish (*fifo, blockSize1 + blockSize2);
249 template <
typename FunctionToApply>
252 for (
auto i = startIndex1, e = startIndex1 + blockSize1; i != e; ++i) func (i);
253 for (
auto i = startIndex2, e = startIndex2 + blockSize2; i != e; ++i) func (i);
256 int startIndex1, blockSize1, startIndex2, blockSize2;
318 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (
AbstractFifo)
336 f.
prepareToRead (num, startIndex1, blockSize1, startIndex2, blockSize2);
342 f.
prepareToWrite (num, startIndex1, blockSize1, startIndex2, blockSize2);
Class for a scoped reader/writer.
#define JUCE_API
This macro is added to all JUCE public class declarations.
void finishedRead(int numRead) noexcept
Called after reading from the FIFO, to indicate that this many items have now been consumed...
~ScopedReadWrite() noexcept
Calls finishedRead or finishedWrite if this is a non-null scoped reader/writer.
void prepareToWrite(int numToWrite, int &startIndex1, int &blockSize1, int &startIndex2, int &blockSize2) const noexcept
Returns the location within the buffer at which an incoming block of data should be written...
Encapsulates the logic required to implement a lock-free FIFO.
void forEach(FunctionToApply &&func) const
Calls the passed function with each index that was deemed valid for the current read/write operation...
ScopedReadWrite(AbstractFifo &f, int num) noexcept
Construct a reader/writer and immediately call prepareRead/prepareWrite on the abstractFifo which was...
void finishedWrite(int numWritten) noexcept
Called after writing from the FIFO, to indicate that this many items have been added.
void prepareToRead(int numWanted, int &startIndex1, int &blockSize1, int &startIndex2, int &blockSize2) const noexcept
Returns the location within the buffer from which the next block of data should be read...