QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RunGuard.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <QtCore/QString>
4
#include <QtCore/QLockFile>
5
6
class
RunGuard
7
{
8
public
:
9
explicit
RunGuard
(
const
QString &key);
10
~RunGuard
();
11
12
// Returns true if another instance holds the lock.
13
bool
isAnotherRunning
();
14
15
// Attempts to acquire the single-instance lock.
16
bool
tryToRun
();
17
18
// Releases the lock if held.
19
void
release
();
20
21
// Optional: returns true if this instance currently holds the lock.
22
bool
isLocked
()
const
{
return
_lockFile.isLocked(); }
23
24
private
:
25
static
QString generateKeyHash(
const
QString &key,
const
QString &salt);
26
static
QString lockDir();
27
28
const
QString _key;
29
const
QString _lockFilePath;
30
QLockFile _lockFile;
31
32
Q_DISABLE_COPY(
RunGuard
)
33
};
RunGuard
Definition
RunGuard.h:7
RunGuard::~RunGuard
~RunGuard()
Definition
RunGuard.cc:16
RunGuard::release
void release()
Definition
RunGuard.cc:55
RunGuard::isLocked
bool isLocked() const
Definition
RunGuard.h:22
RunGuard::tryToRun
bool tryToRun()
Definition
RunGuard.cc:50
RunGuard::isAnotherRunning
bool isAnotherRunning()
Definition
RunGuard.cc:21
src
Utilities
Platform
RunGuard.h
Generated by
1.9.8