Buffered reading from external file

I have code that captures audio and writes it to an external file while processing. Now, I need to be able to read that data back in while processing. Obviously, I can’t read from a file while processing audio, so I want to issue read requests for buffers, in advance of when I need them whenever possible, so that my processing code merely has to ask if the desired buffer is available, and if it is, then get the audio samples needed from that buffer.

Prior to JUCE, I had some fairly complex code that used a thread to monitor read requests, pulled them from a circular fifo, and moved them to a pool of “ready” buffers. A lot of that was using native Mac or Windows code, which I’d like to get rid of in favor of using JUCE cross-platform capabilities.

I have a Thread subclass, and have it calling wait(-1) until signaled, and then when wakened (and not being told to exit) it needs to get the next buffer read request from a circular fifo and perform the read on it before moving it (and its data) to the “ready” pool.

Is there a class that implements any of this already? I see AbstractFifo, and ScopedReadWrite<>, but I don’t see any Tutorials that will help me to know exactly how to use those, or even if they are appropriate for what I need. Is there any example code, or more documentation on how to do this properly in JUCE?

Or should I just use my old plain C++ array and indexes to the head and tail of the queue for this, as I did in my old pre-JUCE code?

By the way, I’m not reading linearly from a single file. I basically need random access to any number of files that have been written already. So I can’t do something like using a single memory-mapped WAV file reader, and I don’t think multiple memory-mapped readers (one for each file) will give me very good performance (and certainly won’t keep the memory footprint down!).