class FileLockMutex 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 $resources

Methods

setTemporaryDirectory($temporaryDirectory)

Set the temporary directory.

string
getFilenameForMutexKey($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.

__destruct()

No description

static bool
isSupported(Application $app)

Is this mutex available for the current system?

acquire(string $key)

Acquire a mutex given its key.

release(string $key)

Release a mutex given its key.

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.

Details

protected setTemporaryDirectory($temporaryDirectory)

Set the temporary directory.

Parameters

$temporaryDirectory

protected string getFilenameForMutexKey($mutexKey)

Get the full path of a temporary file that's unique for the concrete5 application and for the specified mutex key.

Parameters

$mutexKey

Return Value

string

Exceptions

InvalidMutexKeyException

__construct(string $temporaryDirectory)

Initialize the instance.

Parameters

string $temporaryDirectory the path to the temporary directory

__destruct()

static bool isSupported(Application $app)

Is this mutex available for the current system?

Parameters

Application $app

Return Value

bool

See also

\Concrete\Core\System\Mutex\MutexInterface::isSupported()

acquire(string $key)

Acquire a mutex given its key.

If the mutex is already acquired (for example by another process), a.

Parameters

string $key The identifier of the mutex you want to acquire

Exceptions

InvalidMutexKeyException Throws an InvalidMutexKeyException exception if the mutex key is not listed in the app.mutex configuration key
MutexBusyException Throws a MutexBusyException exception if the mutex key is already acquired

See also

\Concrete\Core\System\Mutex\MutexInterface::acquire()

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.

Parameters

string $key The identifier of the mutex you want to release

See also

\Concrete\Core\System\Mutex\MutexInterface::release()

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.

Parameters

string $key The identifier of the mutex
callable $callback The callback function to be executed

Exceptions

InvalidMutexKeyException Throws an InvalidMutexKeyException exception if the mutex key is not listed in the app.mutex configuration key
MutexBusyException Throws a MutexBusyException exception if the mutex key is already acquired

See also

\Concrete\Core\System\Mutex\MutexInterface::execute()