Tripal
|
Public Member Functions | |
acquire ( $name, $timeout=30.0, string $owner='', ?int $pid=NULL) | |
acquireShared (string $name, float $timeout=30.0, string $owner='', ?int $pid=NULL) | |
releaseShared (string $name, string $owner) | |
getStartTime (string $name, ?string $owner=NULL) | |
getOwners (string $name) | |
getOwnerPid (string $name, ?string $owner=NULL) | |
![]() | |
getStartTime (string $name) | |
getCurrentExpirationTime (string $name) | |
getCurrentExpirationDelay (string $name) | |
getOwner (string $name) | |
getOwnerPid (string $name) | |
Shared lock backend interface.
A shared lock allows an element to be locked for one or more operations that can access the locked element concurrently without problems. However, it prevents an operation to acquire an exclusive lock on that element.
The lock meccanism is quite similar to the exclusive one except that more than one operation at a time can aquire a same shared lock. Operations that try to acquire the lock in exclusive mode are denied. Finaly, the lock will only be released once all operations that acquired it released it.
This type of lock is useful when an element needs to be accessed in reading mode by several operations (that wont alter it) but no other operation should be able to alter that element while it is in use by thoses operations.
This interface extends the existing LockBackendInterface interface with 2 new methods that are dedicated to acquire and release a shared lock.
Drupal\tripal_biodb\Lock\SharedLockBackendInterface::acquire | ( | $name, | |
$timeout = 30.0 , |
|||
string | $owner = '' , |
||
?int | $pid = NULL |
||
) |
Acquires a lock.
string | $name | Lock name. Limit of name's length is 255 characters. |
float | $timeout | (optional) Lock lifetime in seconds. Defaults to 30.0. |
string | $owner | (optional) Name of the (exclusive) lock owner. |
?int | $pid (optional) An operating system process ID owning the lock. It may be used to release the lock if the given PID becomes unused. A value of 0 will prevent the share to be released based on a PID. Default: if NULL, the current process ID (getmypid()) will be used. |
Implemented in Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend.
Drupal\tripal_biodb\Lock\SharedLockBackendInterface::acquireShared | ( | string | $name, |
float | $timeout = 30.0 , |
||
string | $owner = '' , |
||
?int | $pid = NULL |
||
) |
Acquires a shared lock.
string | $name | Shared lock name. Limit of name's length is 255 characters. |
float | $timeout | (optional) Shared lock lifetime in seconds. Defaults to 30.0. |
string | $owner | Name of the owner willing a share on the lock (used as identifier). |
?int | $pid (optional) An operating system process ID owning the share. It may be used to release the lock if the given PID becomes unused. A value of 0 will prevent the share to be released based on a PID. Default: if NULL, the current process ID (getmypid()) will be used. |
Implemented in Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend.
Drupal\tripal_biodb\Lock\SharedLockBackendInterface::getOwnerPid | ( | string | $name, |
?string | $owner = NULL |
||
) |
Returns the system process identifier using the shared or exclusive lock.
If no owner is specified, the lock is assumed to be exclusive and 0 will be returned in case of a sheared lock. If an owner is specified, the PID of the owner is returned.
string | $name | Name of the lock. |
?string | $owner Name of the owner of the share of a shared lock. |
Implemented in Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend.
Drupal\tripal_biodb\Lock\SharedLockBackendInterface::getOwners | ( | string | $name | ) |
Returns the list of shared lock owners.
string | $name | Name of the shared lock. |
Implemented in Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend.
Drupal\tripal_biodb\Lock\SharedLockBackendInterface::getStartTime | ( | string | $name, |
?string | $owner = NULL |
||
) |
Returns the time in seconds when the lock started.
If no owner is specified, the lock is assumed to be exclusive and 0 will be returned in case of a shared lock. If an owner is specified, the starting time of the lock share of the specified owner is returned.
string | $name | Name of the lock. |
?string | $owner Name of the owner of the share of a shared lock. |
Implemented in Drupal\tripal_biodb\Lock\PersistentDatabaseSharedLockBackend.
Drupal\tripal_biodb\Lock\SharedLockBackendInterface::releaseShared | ( | string | $name, |
string | $owner | ||
) |
Releases the given shared lock.
string | $name | Lock name. |
string | $owner | Name of the owner of a share on the lock. |