diff options
author | 2021-04-05 23:52:47 +0530 | |
---|---|---|
committer | 2021-04-05 23:52:47 +0530 | |
commit | dd4ccd635326e8036e6431ab43dd3945f99d4ecb (patch) | |
tree | 691ccb265584d47c16e1a855d4d55686d7d602d2 /src/rungaurd.h | |
parent | 939af726dc0b5e07e7d941719dfadf2c9831f4e0 (diff) | |
download | whatsie-dd4ccd635326e8036e6431ab43dd3945f99d4ecb.tar.gz whatsie-dd4ccd635326e8036e6431ab43dd3945f99d4ecb.zip |
runguard class added
Diffstat (limited to '')
-rw-r--r-- | src/rungaurd.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/rungaurd.h b/src/rungaurd.h new file mode 100644 index 0000000..06d45a8 --- /dev/null +++ b/src/rungaurd.h @@ -0,0 +1,32 @@ +#ifndef RUNGUARD_H +#define RUNGUARD_H + +#include <QObject> +#include <QSharedMemory> +#include <QSystemSemaphore> + + +class RunGuard +{ + +public: + RunGuard( const QString& key ); + ~RunGuard(); + + bool isAnotherRunning(); + bool tryToRun(); + void release(); + +private: + const QString key; + const QString memLockKey; + const QString sharedmemKey; + + QSharedMemory sharedMem; + QSystemSemaphore memLock; + + Q_DISABLE_COPY( RunGuard ) +}; + + +#endif // RUNGUARD_H |