PDA

View Full Version : How to avoid conflict, when I read&write one xml from two process?



weidesh
22nd July 2017, 10:02
Hi guys,
recently I'm working on a project which translates three vb6 programs to windows C++ and Linux C++ version with Qt5. In the vb6 programs. The configs were written in windows registry, which I want to change to use xml file.

How can I read and write one xml file at same time in different process?

thx

Radek
22nd July 2017, 12:10
If the file is read-only then you do not need anything special. Simply open the file twice and read. if you are about to write then you need serialization of both writes and reads. Only one thread can read or write the file at one time. Therefore, use mutex (in qt, it is the QMutex class).