Home > Software engineering >  CFile how empty file written content at the same time, does not affect the data in the buffer
CFile how empty file written content at the same time, does not affect the data in the buffer

Time:09-27

Application scenario: a CFile object, continue to write data to the file, at the same time, another thread to read data from CFile object regularly save into small files,
Therefore, after each reading CFile object need to empty has not read the data read some data without affecting the continue to write,

CodePudding user response:

This looks like the Pipe (Pipe) compared with demand

Multithreaded Pipe Server

CodePudding user response:

Need a read-write lock, etc. To be maintained or write multiple files, read the thread finished reading, just delete this file, and then use a set of file name cycle

CodePudding user response:

The best is not divided into two threads, should be run in one thread,
Another suggestion: had better not use CFile object to do this, or use memory to direct exchange is ok

CodePudding user response:

Read the complete can't delete file "? When written in sh create again?

CodePudding user response:

Thread synchronization problem, check on the method of thread synchronization,
Your description and look like is to do a file buffer, so why set up a section of memory as a buffer? CFile why want to use?
  • Related