Entropy Piano Tuner
1.1.3 (documentation not yet complete)
An open-source experimental software for piano tuning by entropy minimization
|
Class for checking whether the application is already running. More...
#include <runguard.h>
Public Member Functions | |
RunGuard (const QString &key) | |
Constructor for a run guard. More... | |
~RunGuard () | |
bool | isAnotherRunning () |
Check whether another instance of the application is running. More... | |
bool | tryToRun () |
Try to run the applicaiton, return false if another instance is running. More... | |
void | release () |
Release the running application. More... | |
Private Member Functions | |
QString | generateKeyHash (const QString &key, const QString &salt) |
Generate hash string for a given keys. More... | |
Private Attributes | |
const QString | key |
Name assigned to the instance. More... | |
const QString | memLockKey |
Key labelling the semaphore lock. More... | |
const QString | sharedmemKey |
Key labelling the shared memory. More... | |
QSharedMemory | sharedMem |
Shared memory labelled by a given key. More... | |
QSystemSemaphore | memLock |
Lock used when shared memory is accessed. More... | |
Class for checking whether the application is already running.
An object of this class can be used to prevent the system from starting serveral instances of the application. There should be no more than one open window of the EPT at a given time.
Internally the instances communicate via a QSharedMemory labelled by a given key. The access to this memory is mutexted by a QSystemSemaphore.
Definition at line 42 of file runguard.h.
RunGuard::RunGuard | ( | const QString & | key | ) |
Constructor for a run guard.
key | : String naming the run guard (e.g. entropypianotuner_runguard) |
Definition at line 39 of file runguard.cpp.
|
inline |
|
private |
Generate hash string for a given keys.
This function converts a key (entropypianotuner_runguard) and a second key extenstion (e.g._memLockKey) into a hash string.
key | : String holding the key |
salt | : String holding the key extension |
Definition at line 64 of file runguard.cpp.
bool RunGuard::isAnotherRunning | ( | ) |
Check whether another instance of the application is running.
This function checks first whether the own instance is already running. Then it checks whether another application has already created the shared memory, indicating that another instance of the same applicaiton is running.
Definition at line 91 of file runguard.cpp.
void RunGuard::release | ( | ) |
Release the running application.
This function detaches the application from the shared memery. It has to be called when the application terminates.
Definition at line 144 of file runguard.cpp.
bool RunGuard::tryToRun | ( | ) |
Try to run the applicaiton, return false if another instance is running.
This function tries to create the shared memory and attach itself to it, indicating that this is the running instance of the EPT-
Definition at line 122 of file runguard.cpp.
|
private |
Name assigned to the instance.
Definition at line 55 of file runguard.h.
|
private |
Lock used when shared memory is accessed.
Definition at line 60 of file runguard.h.
|
private |
Key labelling the semaphore lock.
Definition at line 56 of file runguard.h.
|
private |
Shared memory labelled by a given key.
Definition at line 59 of file runguard.h.
|
private |
Key labelling the shared memory.
Definition at line 57 of file runguard.h.