\Imi\Lock\HandlerILockHandler

Summary

Methods
Constants
__construct()
lock()
tryLock()
unlock()
isLocked()
getId()
close()
getWaitTimeout()
getLockExpire()
getLockCoId()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

__construct()

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

Parameters

$id
$options

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

getId()

getId() : string

获取锁的唯一ID

Returns

string

close()

close() : void

解锁并释放所有资源

getWaitTimeout()

getWaitTimeout() : integer

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

Returns

integer

getLockExpire()

getLockExpire() : integer

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

Returns

integer

getLockCoId()

getLockCoId() : integer

获取获得锁的协程ID

Returns

integer