PHP Класс yii\mutex\Mutex

This is achieved by using a "lock" mechanism. Each possibly concurrent thread cooperates by acquiring a lock before accessing the corresponding data. Usage example: if ($mutex->acquire($mutexName)) { business logic execution } else { execution is blocked! } This is a base class, which should be extended in order to implement the actual lock mechanism.
С версии: 2.0
Автор: resurtm ([email protected])
Наследование: extends yii\base\Component
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$autoRelease whether all locks acquired in this process (i.e. local locks) must be released automatically before finishing script execution. Defaults to true. Setting this property to true means that all locks acquired in this process must be released (regardless of errors or exceptions).

Открытые методы

Метод Описание
acquire ( string $name, integer $timeout ) : boolean Acquires a lock by name.
init ( ) Initializes the Mutex component.
release ( string $name ) : boolean Releases acquired lock. This method will return false in case the lock was not found.

Защищенные методы

Метод Описание
acquireLock ( string $name, integer $timeout ) : boolean This method should be extended by a concrete Mutex implementations. Acquires lock by name.
releaseLock ( string $name ) : boolean This method should be extended by a concrete Mutex implementations. Releases lock by given name.

Описание методов

acquire() публичный Метод

Acquires a lock by name.
public acquire ( string $name, integer $timeout ) : boolean
$name string of the lock to be acquired. Must be unique.
$timeout integer time to wait for lock to be released. Defaults to zero meaning that method will return false immediately in case lock was already acquired.
Результат boolean lock acquiring result.

acquireLock() абстрактный защищенный Метод

This method should be extended by a concrete Mutex implementations. Acquires lock by name.
abstract protected acquireLock ( string $name, integer $timeout ) : boolean
$name string of the lock to be acquired.
$timeout integer time to wait for the lock to be released.
Результат boolean acquiring result.

init() публичный Метод

Initializes the Mutex component.
public init ( )

release() публичный Метод

Releases acquired lock. This method will return false in case the lock was not found.
public release ( string $name ) : boolean
$name string of the lock to be released. This lock must already exist.
Результат boolean lock release result: false in case named lock was not found..

releaseLock() абстрактный защищенный Метод

This method should be extended by a concrete Mutex implementations. Releases lock by given name.
abstract protected releaseLock ( string $name ) : boolean
$name string of the lock to be released.
Результат boolean release result.

Описание свойств

$autoRelease публичное свойство

whether all locks acquired in this process (i.e. local locks) must be released automatically before finishing script execution. Defaults to true. Setting this property to true means that all locks acquired in this process must be released (regardless of errors or exceptions).
public $autoRelease