PHP Class PHPDaemon\Core\Timer

Author: Vasily Zorin ([email protected])
Inheritance: use trait PHPDaemon\Traits\ClassWatchdog, use trait PHPDaemon\Traits\StaticObjectWatchdog, use trait PHPDaemon\Traits\EventLoopContainer
Datei anzeigen Open project: kakserpom/phpdaemon Class Usage Examples

Public Properties

Property Type Description
$cb Callback
$finished Is the timer finished?
$id Timer id
$lastTimeout Current timeout holder
$priority Priority

Protected Properties

Property Type Description
$counter Counter
$ev Event resource
$list List of timers

Public Methods

Method Description
__construct ( callable $cb, integer $timeout = null, integer | string $id = null, integer $priority = null ) Constructor
__destruct ( ) : void Destructor
add ( callable $cb, integer $timeout = null, integer | string $id = null, integer $priority = null ) : integer | string Adds timer
cancel ( ) : void Cancels timer
cancelTimeout ( integer | string $id ) : void Cancels timer by ID
eventCall ( ) : void Called when timer is triggered
finish ( ) : void Finishes timer
free ( ) : void Frees the timer
remove ( integer | string $id ) : void Removes timer by ID
setPriority ( integer $priority ) : void Set prioriry
setTimeout ( integer | string $id, integer $timeout = null ) : boolean Sets timeout
timeout ( integer $timeout = null ) : void Sets timeout

Method Details

__construct() public method

Constructor
public __construct ( callable $cb, integer $timeout = null, integer | string $id = null, integer $priority = null )
$cb callable Callback
$timeout integer Timeout
$id integer | string Timer ID
$priority integer Priority

__destruct() public method

Destructor
public __destruct ( ) : void
return void

add() public static method

Adds timer
public static add ( callable $cb, integer $timeout = null, integer | string $id = null, integer $priority = null ) : integer | string
$cb callable Callback
$timeout integer Timeout
$id integer | string Timer ID
$priority integer Priority
return integer | string Timer ID

cancel() public method

Cancels timer
public cancel ( ) : void
return void

cancelTimeout() public static method

Cancels timer by ID
public static cancelTimeout ( integer | string $id ) : void
$id integer | string Timer ID
return void

eventCall() public method

Called when timer is triggered
public eventCall ( ) : void
return void

finish() public method

Finishes timer
public finish ( ) : void
return void

free() public method

Frees the timer
public free ( ) : void
return void

remove() public static method

Removes timer by ID
public static remove ( integer | string $id ) : void
$id integer | string Timer ID
return void

setPriority() public method

Set prioriry
public setPriority ( integer $priority ) : void
$priority integer Priority
return void

setTimeout() public static method

Sets timeout
public static setTimeout ( integer | string $id, integer $timeout = null ) : boolean
$id integer | string Timer ID
$timeout integer Timeout
return boolean

timeout() public method

Sets timeout
public timeout ( integer $timeout = null ) : void
$timeout integer Timeout
return void

Property Details

$cb public_oe property

Callback
public $cb

$counter protected_oe static_oe property

Counter
protected static $counter

$ev protected_oe property

Event resource
protected $ev

$finished public_oe property

Is the timer finished?
public $finished

$id public_oe property

Timer id
public $id

$lastTimeout public_oe property

Current timeout holder
public $lastTimeout

$list protected_oe static_oe property

List of timers
protected static $list

$priority public_oe property

Priority
public $priority