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.
파일 보기
프로젝트 열기: yiisoft/yii2
1 사용 예제들
공개 프로퍼티들
프로퍼티 |
타입 |
설명 |
|
$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). |
|
공개 메소드들
보호된 메소드들
메소드 |
설명 |
|
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. |
|
메소드 상세
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.
Initializes the Mutex component.
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.
프로퍼티 상세
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).