SemaphoreMutex
class SemaphoreMutex implements MutexInterface (View source)
Traits
Trait that contains stuff that can be useful for Mutexes.
Properties
protected string | $temporaryDirectory | The temporary directory. |
from MutexTrait |
protected array | $semaphores |
Methods
Get the full path of a temporary file that's unique for the concrete5 application and for the specified mutex key.
Initialize the instance.
Acquire a mutex given its key.
Release a mutex given its key.
Execute a callable by acquiring and releasing a mutex, so that the callable won't be executed by multiple processes concurrently.
Details
protected
setTemporaryDirectory(mixed $temporaryDirectory)
Set the temporary directory.
protected string
getFilenameForMutexKey(mixed $mutexKey)
Get the full path of a temporary file that's unique for the concrete5 application and for the specified mutex key.
__construct(string $temporaryDirectory)
Initialize the instance.
static bool
isSupported(Application $app)
Is this mutex available for the current system?
acquire(string $key)
Acquire a mutex given its key.
If the mutex is already acquired (for example by another process), a.
release(string $key)
Release a mutex given its key.
If the mutex not already acquired nothing happens. When the current PHP process ends, the mutex will be released automatically.
execute(string $key, callable $callback)
Execute a callable by acquiring and releasing a mutex, so that the callable won't be executed by multiple processes concurrently.