Cooporating with RtPlot

The user can do two things to cooperate programmatically with RtPlot: (1) Change the write-time of the file instead of relying on the Operating System and (2) Use a mutex to prevent simultaneous access to the data file by both RtPlot and another program.

To change the programmatically the write-time of the file, the user can call the SetFileTime API immediately following writing the data to the file and flushing its contents. See the sample testplot program in the package for an example.

To eliminate the possibility of RtPlot and the program that writes the data try to access the same file simultaneously, RtPlot uses a mutex when it reads the data. The name of this mutex is RtPlotMutex.

The program that writes the data can also use a mutex with the same name to lock access to the file while it write or updates the write time of the output file. In C++ it can be done nearly transparently by using an object which locks the file using the RtPlotMutex mutex in its constructor and releases it in the destructor.

The program testplot included in the package uses the Lock object defined in the header file mutex.hpp (see for example the chapter on Using Threads in this win32 tutorial ). testplot uses the Lock object to lock the output file from RtPlot just before writing the data to the file and changing the write time of the output file. It releases it immediately after.