0

I had a server programm that takes settings from a file. I tried to lock while reading it using QReadWriteLock class allocated dynamically in my own class and released to free store in destructor of my class object of which exists in main(). My major was to lock it, so that if launched, the second time .exe of the programm it couldn't get access so that I could have had a Singleapplication Compiling shows no error but when I launch my server from second .exe (yet the first functioning) it also has a access to settings. What is my mistake or I'm not suppose to utilize QReadWriteLock in this case, due to it's related to threads only? Not to seperate executables?

4

1 回答 1

0

QReadWriteLock用于在单个应用程序中同步生产者/消费者类线程。如果你想防止多次启动同一个可执行文件,你可以使用 PID 文件或类似的东西。另一种选择是使用 QtSolutions-plugin 中的 QtSingleApplication 代码:Qt: Best practice for a single instance app protection

于 2013-08-29T11:10:31.657 回答