Detailed Description
ConcurrencyManager is used to handle concurrency for objects.
Depending on the lock type, locking has different semantics:
- Optimistic locks can be aquired on the same object by different users. This lock quarantees that an exception is thrown, if the user tries to persist an object, which another used has updated, since the user retrieved it.
- Pessimistic (write) locks can be aquired on the same object only by one user. This lock quarantees that no other user can modify the object until the lock is released. A user can only aquire one lock on each object. An exeption is thrown, if a user tries to aquire a lock on an object on which another user already owns a pessimistic lock.
Definition at line 32 of file ConcurrencyManager.php.
Public Member Functions | |
aquireLock (ObjectId $oid, $type, PersistentObject $currentState=null) | |
releaseLock (ObjectId $oid, $type=null) | |
releaseLocks (ObjectId $oid) | |
releaseAllLocks () | |
getLock (ObjectId $oid) | |
checkPersist (PersistentObject $object) | |
updateLock (ObjectId $oid, PersistentObject $object) | |
Member Function Documentation
◆ aquireLock()
aquireLock | ( | ObjectId | $oid, |
$type, | |||
PersistentObject | $currentState = null |
||
) |
Aquire a lock on an ObjectId for the current user.
Throws an exception if locking fails.
- Parameters
-
$oid The object id of the object to lock. $type One of the Lock::Type constants. $currentState PersistentObject instance defining the current state for an optimistic lock (optional, if not given, the current state will be loaded from the store)
Implemented in DefaultConcurrencyManager.
◆ releaseLock()
releaseLock | ( | ObjectId | $oid, |
$type = null |
|||
) |
Release a lock on an ObjectId for the current user.
- Parameters
-
$oid object id of the object to release. $type One of the Lock::Type constants or null for all types (default: null)
Implemented in DefaultConcurrencyManager.
◆ releaseLocks()
releaseLocks | ( | ObjectId | $oid | ) |
Release all locks on an ObjectId regardless of the user.
- Parameters
-
$oid object id of the object to release.
Implemented in DefaultConcurrencyManager.
◆ releaseAllLocks()
releaseAllLocks | ( | ) |
Release all locks for the current user.
Implemented in DefaultConcurrencyManager.
◆ getLock()
getLock | ( | ObjectId | $oid | ) |
Get the lock for an object id.
- Parameters
-
$oid object id of the object to get the lock data for.
- Returns
- Lock instance or null
Implemented in DefaultConcurrencyManager.
◆ checkPersist()
checkPersist | ( | PersistentObject | $object | ) |
Check if the given object can be persisted.
Throws an exception if not.
- Parameters
-
$object The object to check.
Implemented in DefaultConcurrencyManager.
◆ updateLock()
updateLock | ( | ObjectId | $oid, |
PersistentObject | $object | ||
) |
Update the current state of the lock belonging to the given object if existing and owned by the current.
- Parameters
-
$oid The object id. $object The updated object data.
Implemented in DefaultConcurrencyManager.