KDBusAddons 5.109.0
|
A class for serializing access to a resource that is shared between multiple processes. More...
#include <KDBusInterProcessLock>
Signals | |
void | lockGranted (KDBusInterProcessLock *lock) |
This signal is emitted when the requested lock has been granted. | |
Public Member Functions | |
KDBusInterProcessLock (const QString &resource) | |
Creates a new inter process lock object. | |
~KDBusInterProcessLock () override | |
Destroys the inter process lock object. | |
void | lock () |
Requests the lock. | |
QString | resource () const |
Returns the identifier of the resource the lock is set on. | |
void | unlock () |
Releases the lock. | |
void | waitForLockGranted () |
Waits for the granting of a lock by starting an internal event loop. | |
A class for serializing access to a resource that is shared between multiple processes.
This class can be used to serialize access to a resource between multiple processes. Instead of using lock files, which could become stale easily, the registration of dummy D-Bus services is used to allow only one process at a time to access the resource.
Example:
KDBusInterProcessLock::KDBusInterProcessLock | ( | const QString & | resource | ) |
Creates a new inter process lock object.
resource | The identifier of the resource that shall be locked. This identifier can be any string, however it must be unique for the resource and every client that wants to access the resource must know it. |
|
override |
Destroys the inter process lock object.
void KDBusInterProcessLock::lock | ( | ) |
Requests the lock.
The lock is granted as soon as the lockGranted() signal is emitted.
|
signal |
This signal is emitted when the requested lock has been granted.
lock | The lock that has been granted. |
QString KDBusInterProcessLock::resource | ( | ) | const |
Returns the identifier of the resource the lock is set on.
void KDBusInterProcessLock::unlock | ( | ) |
Releases the lock.
void KDBusInterProcessLock::waitForLockGranted | ( | ) |
Waits for the granting of a lock by starting an internal event loop.