My code has a data structure say for example "vector of vector of Strings. I've 2 threads:
Thread 1 is writing data to this data structure (buffer in RAM).
Thread 2 running in parallel which should copy data FROM the above buffer i.e data structure TO a file for every "x" milliseconds.
I'm wondering how would I achieve this in C++ ? It should consider key points in problem statement like:
- The copy from buffer to file should happen only once in "X" milliseconds.
- Synchronization between both threads.
EDITING THE QUERY WITH MORE DETAILS PER THE ASK
I want to build a library (*.lib) & this library exposes some APIs hence it gets input data from EXE or any entity which uses my library through these APIs.
Say the data received by my library is in the form of a vector of strings.
FillLibraryDataStructure(std::vector); // is the API of this library. Any app can call this API & pass a vector of string to this library. Example app code:
for(int i=100; i
Источник: https://stackoverflow.com/questions/448 ... data-struc
Мобильная версия