I get a lot of data at a fixed rate. I need to do some processing of this data in another thread, but it may work slower than the data arrives, so I need to buffer the data. Due to the amount of data entering the available RAM, it will be quickly exhausted, so it should overflow on the hard drive. What I can do is something like a file supported by the file system, so the script may be blocked by the file system, but not too slow reading the reader.
Here is an approximate set of requirements:
- Writing should not be blocked by a reader working too slowly.
- If the data is considered to be slow enough so that the available RAM is exhausted, it should overflow into the file system. This is normal for writing to a disk to lock.
- Reading should be blocked if data is not available, if the stream was not closed by the writer.
- If the reader can keep up with the data, he should never get on the hard drive, since the RAM buffer will be enough (good, but not significant).
- Disk space should be recovered as data is consumed (or soon after).
Is there such a mechanism in Windows?
source
share