Lock-free FIFO - amount available?

When I do a read from my FIFO, I’d like to know how much is available, so I can tell if I may run out (I suppose I could do the same when writing?).

But both the read and write only give me back the amount I asked for, as I understand it, and I’d like to know the total amount available.

Would there be any problem asking for ‘all’ of the buffered data (just using the max possible) and then just using a small subset? Any speed penalties or possible locking etc.?

Bruce