Skip to content

Periodic timer jumping from one value to another directly. #225

@CherukuriSiva

Description

@CherukuriSiva

Thank You for open sourcing this great project.

I am using event-loops in one of my WebSocket(RatchetPHP) related projects.

I am running a periodic timer for every 0.1 seconds and the counter will start from 10. Every iteration I am decreasing 0.1 from the counter. So I should get values like 9.9, 9.8, 9.7 like this... till 0.0.

I have written the below code. It is working fine on my localhost but on the server machine, the values are jumping from 9.9 to 9.6 to 9.3 like this...

I have deployed my code Digital Ocean's hosting server.
It is running on Ubuntu OS.
1 GB RAM. 25GB HardDisk.
I actually took the Basic plan. Can this be the reason? Because of limited RAM and availabe space, I am facing this issue.

KIndly help me.

        $seconds_counter = 10;
        $loop->addPeriodicTimer(0.1, function(TimerInterface $timer)  use(&$seconds_counter, $loop) {
            $seconds_counter = $seconds_counter-0.1;

            if($seconds_counter <= 0.0) {
                $loop->cancelTimer($timer);
            }
        });

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions