aboutsummaryrefslogtreecommitdiff
path: root/src/rungaurd.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/rungaurd.h')
-rw-r--r--src/rungaurd.h32
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