class Timer

Constants

STOP

Methods

__construct(LoggerInterface|null $logger = null)

Create a new timer instance.

int
after(float $timeout, callable $closure, string $identifier = Constants::WORKER_EXIT)

Execute a callback after a given timeout or when the identifier is resumed.

int
tick(float $timeout, callable $closure, string $identifier = Constants::WORKER_EXIT)

Execute a callback repeatedly at a given interval until stopped or the identifier is resumed.

int
until(callable $closure, string $identifier = Constants::WORKER_EXIT)

Execute a callback when the identifier is resumed.

void
clear(int $id)

Clear a registered timer callback by its ID.

void
clearAll()

Clear all registered timer callbacks.

static array
stats()

Get the current timer statistics.

static void
flushState()

Flush all static state.

Details

at line 41
__construct(LoggerInterface|null $logger = null)

Create a new timer instance.

Parameters

LoggerInterface|null $logger

at line 48
int after(float $timeout, callable $closure, string $identifier = Constants::WORKER_EXIT)

Execute a callback after a given timeout or when the identifier is resumed.

Parameters

float $timeout
callable $closure
string $identifier

Return Value

int

at line 97
int tick(float $timeout, callable $closure, string $identifier = Constants::WORKER_EXIT)

Execute a callback repeatedly at a given interval until stopped or the identifier is resumed.

Parameters

float $timeout
callable $closure
string $identifier

Return Value

int

at line 198
int until(callable $closure, string $identifier = Constants::WORKER_EXIT)

Execute a callback when the identifier is resumed.

Parameters

callable $closure
string $identifier

Return Value

int

at line 206
void clear(int $id)

Clear a registered timer callback by its ID.

Parameters

int $id

Return Value

void

at line 221
void clearAll()

Clear all registered timer callbacks.

Return Value

void

at line 233
static array stats()

Get the current timer statistics.

Return Value

array

at line 258
static void flushState()

Flush all static state.

Return Value

void