Properties

$atomicName

$atomicName : string

配置的 Atomic 名称

Type

string

$quantity

$quantity : integer

同时获得锁的数量

Type

integer

$id

$id : string

锁的唯一 ID

Type

string

$isLocked

$isLocked : boolean

是否已加锁

Type

boolean

$waitTimeout

$waitTimeout : integer

等待锁超时时间,单位:毫秒,0为不限制

Type

integer

$lockExpire

$lockExpire : integer

锁超时时间,单位:毫秒

Type

integer

$lockCoId

$lockCoId : integer

获得锁的协程ID

Type

integer

$timeoutTimerId

$timeoutTimerId : integer

超时 timerid

Type

integer

Methods

__construct()

__construct(  $id,   $options = array()) 

Parameters

$id
$options

getId()

getId() : string

获取锁的唯一ID

Returns

string

lock()

lock(callable  $taskCallable = null, callable  $afterLockCallable = null) : boolean

加锁,会挂起协程

Parameters

callable $taskCallable

加锁后执行的任务,可为空;如果不为空,则执行完后自动解锁

callable $afterLockCallable

当获得锁后执行的回调,只有当 $taskCallable 不为 null 时有效。该回调返回 true 则不执行 $taskCallable

Returns

boolean

tryLock()

tryLock(callable  $taskCallable = null) : boolean

尝试获取锁

Parameters

callable $taskCallable

加锁后执行的任务,可为空;如果不为空,则执行完后自动解锁

Returns

boolean

unlock()

unlock() : boolean

解锁

Returns

boolean

isLocked()

isLocked() : boolean

获取当前是否已获得锁状态

Returns

boolean

close()

close() : void

解锁并释放所有资源

getWaitTimeout()

getWaitTimeout() : integer

Get 等待锁超时时间,单位:毫秒,0为不限制

Returns

integer

getLockExpire()

getLockExpire() : integer

Get 锁超时时间,单位:毫秒

Returns

integer

getLockCoId()

getLockCoId() : integer

获取获得锁的协程ID

Returns

integer

__close()

__close() : void

解锁并释放所有资源

__lock()

__lock() : boolean

加锁,会阻塞进程

Returns

boolean

__tryLock()

__tryLock() : boolean

尝试获取锁

Returns

boolean

__unlock()

__unlock() : boolean

解锁

Returns

boolean

startTimeoutTimer()

startTimeoutTimer() : void

开启超时计时器

stopTimeoutTimer()

stopTimeoutTimer() : void

停止超时计时器