Skip to content

Manual "tick" execution #216

Description

@SerafimArts

I suggest adding a manual tick() call to the loop:

interface LoopInterface
{
// ...publicfunctiontick(): void;
}

In this case, the implementation of the run() method will be as follows:

publicfunctionrun()
{
$this->running = true;
while ($this->running) {
$this->tick();
}
} 

Such functionality is extremely necessary if the implementation uses its own event loop.
Such cases are needed when you need to implement additional functionality, for example, add support for high-performance tick handlers. For example:

class MyLoop
{
publicfunction__construct(LoopInterface$parent) { ... }
publicfunctionrun(): void
{
while(true) {
$now = \microtime(true);
$delta = $now - $this->updated;
// custom operationsforeach ($this->ticksas$handler) {
$handler($delta);
}
$this->parent->tick();
$this->updated = $now;
}
} }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions