You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
821 B
39 lines
821 B
9 years ago
|
/****************************************************************************
|
||
|
*
|
||
|
* (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||
|
*
|
||
|
* QGroundControl is licensed according to the terms in the file
|
||
|
* COPYING.md in the root of the source code directory.
|
||
|
*
|
||
|
****************************************************************************/
|
||
|
|
||
|
#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
|