Base class for locks, like file locks.
libphutil provides a concrete lock in PhutilFileLock.
$lock->lock(); do_contentious_things(); $lock->unlock();
If the lock can't be acquired because it is already held, PhutilLockException is thrown. Other exceptions indicate permanent failure unrelated to locking.
|parameters||string||$name||Globally unique lock name.|
Build a new lock, given a lock name. The name should be globally unique across all locks.
|parameters||float||$wait||Seconds to block waiting for the lock.|
Acquires the lock, or throws PhutilLockException if it fails.
Releases the lock.
Get a named lock, if it has been registered.
|return||string||Globally unique lock name, across all locks.|
Returns a globally unique name for this lock.
|return||bool||True if the lock is held.|
Determine if the lock is currently held.
|parameters||float||$wait||Seconds to block waiting for the lock. By default, do not block.|
Acquire the lock. If lock acquisition fails because the lock is held by another process, throws PhutilLockException. Other exceptions indicate that lock acquisition has failed for reasons unrelated to locking.
If the lock is already held by this process, this method throws. You can test the lock status with isLocked().
|parameters||PhutilLock||$lock||Lock to register.|
Register a lock for cleanup when the process exits.
Release the lock. Throws an exception on failure, e.g. if the lock is not currently held.
On shutdown, we release all the locks. You should not call this method directly. Use unlock() to release individual locks.