Class Waitable
Abstraction for objects which can be checked (non-blocking) or waited upon to
resolve (blocking, with optional timeout).
Methods summary
public
|
|
public
mixed
|
#
__invoke( )
Immediately return the value of the Waitable, resolved or not
Immediately return the value of the Waitable, resolved or not
Returns
mixed current value
|
public
boolean
|
#
check( )
Returns whether or not the Waitable is resolved.
Returns whether or not the Waitable is resolved.
Returns
boolean resolved or not
|
protected
|
#
precheck( )
Subclasses override this to do something during check()
Subclasses override this to do something during check()
|
public
this
|
#
resolve( mixed $result )
Resolve the Waitable to a value, Exception, or NULL to leave it
unresolved.
Resolve the Waitable to a value, Exception, or NULL to leave it
unresolved.
Parameters
Returns
this
|
public
|
#
timeout( integer $ms = 0, integer $spin = 10, boolean $reset = false )
Sets the timeout for this Waitable. $obj->timeout() will cause the
Waitable to not wait at all.
Sets the timeout for this Waitable. $obj->timeout() will cause the
Waitable to not wait at all.
Parameters
- $ms
integer $ms in milliseconds. 0 = immediately, null = never
- $spin
integer $spin delay between spinlock checks
- $reset
boolean $reset whether or not to reset the timer
|
public
string|null
|
#
type( )
Get the expected result type, if any, of this Waitable.
Get the expected result type, if any, of this Waitable.
Returns
string|null
|
public
mixed
|
#
wait( )
Blocks until either the Waitable resolves or times out.
Blocks until either the Waitable resolves or times out.
Returns
mixed $result resolved value or an Exception
|
public
mixed
|
#
expect( )
Same as wait(), except it throws Exceptions instead of returning them.
Same as wait(), except it throws Exceptions instead of returning them.
Returns
mixed $result resolved value
|