I am using an external library which is creating a large amount (>4GB)of binary data. I want to buffer this data and feed it to a second library while it is still being created.
My program is a 64 bit process, running on Linux. I cannot make any guarantees about the system which is going to be running it regarding its RAM.
For the first library I implement a virtual function which the library calls, to feed me with the binary data:
virtual void put_data(uint8_t* data, size_t s_data);
I am free to do whatever I want in the implemented function with this data.
The second library expects similarly this data in chunks of 100 bytes. The function looks like that:
void write(const uint8_t* buffer);
So what I could do in theory is start the first lib in one thread, the second lib in a second and while the data is coming from the first lib, in a loop feed this data to the second lib if it is available. Now obviously I cannot just forward the buffers because they might have a different size. Is there a convenient way of doing this in C++, or do I have to write a new Class for that?