I have a file that's too big to be read all at once. It must be processed in chunks.
I'm envisioning a background load system that works on two buffers: One for processing, one for reading into (and swapping them all the time).
In Pseudo-Code:
Read Buf1
Mark Buf2 as dirty, so background task will fill it with new data
Process Buf1
if(Reached End of Buf1)
Block if Buf2 still marked as dirty
Swap Buf1 <-> Buf2
Mark Buf2 as dirty
Process Buf1
... and so on.
There are going to be many chunks. Would it be better to put a dedicated reading thread on this or is it "ok" to launch an std::async for every read operation? Because I'm told that these launch their own threads internally, which is expensive.
Yes, it is time critical.
Aucun commentaire:
Enregistrer un commentaire