How to write data into a buffer and write the buffer into a binary file with a second thread?
NickName:Snoopyjackson Ask DateTime:2015-08-13T20:37:16

How to write data into a buffer and write the buffer into a binary file with a second thread?

I am getting data from a sensor(camera) and writing the data into a binary file. The problem is it takes lot of space on the disk. So, I used the compression from boost (zlib) and the space reduced a lot! The problem is the compression process is slow and lots of data is missing.

So, I want to implement two threads, with one getting the data from the camera and writing the data into a buffer. The second thread will take the front data of the buffer and write it into the binary file. And in this case, all the data will be present.

How do I implement this buffer? It needs to expand dynamically and pop_front. Shall I use std::deque, or does something better already exist?

Copyright Notice:Content Author:「Snoopyjackson」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/31988468/how-to-write-data-into-a-buffer-and-write-the-buffer-into-a-binary-file-with-a-s

More about “How to write data into a buffer and write the buffer into a binary file with a second thread?” related questions

How to write data into a buffer and write the buffer into a binary file with a second thread?

I am getting data from a sensor(camera) and writing the data into a binary file. The problem is it takes lot of space on the disk. So, I used the compression from boost (zlib) and the space reduced...

Show Detail

write a float buffer to a binary file

I have a float buffer with the data of the ppm file. The buffer[0][0] is the 1st element and the buffer[3*width*height][0] is the last element of the data. Buffer has elements like this. 1st = 117 ...

Show Detail

C: read binary file to memory, alter buffer, write buffer to file

The goal: Open a file with binary data, read the whole file into memory, change some parts oft he file, write the memory buffer to the file, close the file. Profit? The problem: I have just star...

Show Detail

Write Binary file from char buffer on linux

So i am new to linux programming on C++ and i am trying to write the contents of a binary file (.dll, .exe etc) to a .txt to test and see the results of the operation, the code works and writes the...

Show Detail

Making write buffer available for flushing by another thread

I have a scenario where I want to write data behind an API call to disk. Performance is critical so I write data per thread to separate per-thread files. To optimize the write, I buffer data in mem...

Show Detail

node js - write buffer to file

I've been trying to make a simple copy/paste program in Node JS but can't do it because of a problem. I am able to copy the contents of source file as Buffer and write it to another file but while

Show Detail

How to buffer stdout in memory and write it from a dedicated thread

I have a C application with many worker threads. It is essential that these do not block so where the worker threads need to write to a file on disk, I have them write to a circular buffer in memo...

Show Detail

Write structure to a binary file, read it from file, store in buffer, print the buffer

I am trying to write a structure to a binary file, the punctuation will be received as a parameter in the insertInFile function, (working with raspberryPi, and store the values of the time reaction...

Show Detail

How to read file, convert binary buffer to binary string and later convert the binary string to binary buffer again in C?

I would like to write a program that could read a file, let's say myfile.bin, convert the buffer to binary 'string' ("101110111011..."), store that in a char* variable. Later, I would like to be ab...

Show Detail

Write raw binary data to Buffer

I am working on a function that iterates over PCM data. I am getting chunks of data of varying size and I am currently handling this by buffer concatenation. Problem is, I am quite sure that this

Show Detail