Hello,

I'm thinking about the idea of developing a pair of softwares, the second devoted to provide some data to the first one. Essentially what the second app will do is to periodically download data from the web and provide it in an organized way in a text (.txt) file (or maybe XML). And this data will be read by the first app, who will use it at will.

The problem is the sync: how could I be sure that the first app will not try to read from the file at the same time the second is writing on (or erasing) it? Notice that this all happens in an asynchronous way (there is no telling when the first app will decide to read the file, and there is no specification yet when the second will be started to do its job - it may start working by a QProcess call from the first at any time or together with it on its initialization).

The question is: how to make sure there will be no problems in this write/read process?

I though about two solutions: in one, both of them would be talking to each other by another, secondary simple .txt file. On it, a simple "0 or 1" signal would be used by one of them to know if they can either read or write to the data file. The problem for me is that even a single-byte file could lead to the same read/write problems I'm trying to run away from. And the second solution is to use QProcess to make them talk to each other in a similar algorithmic way like it would be done in the first solution.


So is there a better way of doing this? Could Qt help someway?

Thanks,

Momergil