#include <appinst.h>
Public Member Functions | |
| AppInstance (const std::string &rName, const std::string &rBase=APPLOCK_BASEDIR) | |
| Constructor. | |
| ~AppInstance () | |
| Destructor. | |
| bool | Lock () |
| Attempts to lock the instance. | |
| void | Unlock () |
| Unlocks the instance. | |
| bool | Exists () const |
| Checks whether an instance of this application exists. | |
| bool | SendSignal (int iSigNo) const |
| Sends a signal to an instance of this application. | |
| bool | Terminate () const |
| Terminates an instance of this application. | |
Protected Member Functions | |
| bool | DoLock () |
This class is intended for application which require to be running only once (one instance only). It provides some methods for simple locking, signaling etc.
| AppInstance::AppInstance | ( | const std::string & | rName, | |
| const std::string & | rBase = APPLOCK_BASEDIR | |||
| ) |
Constructor.
| [in] | rName | application name |
| [in] | rBase | lockfile base directory |
| AppInstance::~AppInstance | ( | ) |
Destructor.
| bool AppInstance::Lock | ( | ) |
Attempts to lock the instance.
This method attempts to create a lockfile. If the file already exists it checks whether its owner is still living. If it does this method fails. Otherwise it unlinks this file and re-attempts to create it.
| void AppInstance::Unlock | ( | ) |
Unlocks the instance.
This method removes (unlinks) the appropriate lockfile. If the instance hasn't been locked this method has no effect.
| bool AppInstance::Exists | ( | ) | const |
Checks whether an instance of this application exists.
If this instance has acquired the lockfile the call will be successful. Otherwise it checks for existence of another running instance.
| bool AppInstance::SendSignal | ( | int | iSigNo | ) | const |
Sends a signal to an instance of this application.
This method doesn't signal the current instance.
| [in] | iSigNo | signal number |
| bool AppInstance::Terminate | ( | ) | const [inline] |
Terminates an instance of this application.
This method doesn't terminate the current instance.
| bool AppInstance::DoLock | ( | ) | [protected] |
1.5.1