Giter Club home page Giter Club logo

Comments (4)

lucasnetau avatar lucasnetau commented on June 14, 2024 1

The ExtEvLoop implementation did not take into account the adjusted min bounded $interval stored in Timer. EvTimer was being initialised with a repeat value of 0, completing after the first invocation of the timer. A simple patch is proposed in PR #243

from event-loop.

WyriHaximus avatar WyriHaximus commented on June 14, 2024

To be honest, I'm not sure, adding a periodic timer with an interval of 0 is not an expected thing to do. Theoretically, it should trigger every loop iteration, creating a very busy loop, and completely utilizing a full CPU core.

I'm assuming you want to have that function called a lot, and guessing 100 times a second is enough then using 0.01 should do the trick.

from event-loop.

amir-khoshbakht avatar amir-khoshbakht commented on June 14, 2024

To be honest, I'm not sure, adding a periodic timer with an interval of 0 is not an expected thing to do. Theoretically, it should trigger every loop iteration, creating a very busy loop, and completely utilizing a full CPU core.

I'm assuming you want to have that function called a lot, and guessing 100 times a second is enough then using 0.01 should do the trick.

in the path : React\EventLoop\Timer\Timer

const MIN_INTERVAL = 0.000001;
if ($interval < self::MIN_INTERVAL) {
    $interval = self::MIN_INTERVAL;
}

There is a piece of logic in the timer class constructor that if the time is less than the minimum time, the minimum time is selected. But by selecting zero time, the timer no longer works periodically. And calls the callback only once

Even if I choose very small number instead of zero, the timer works periodically

$this->loop->addPeriodicTimer(0.0000000000000000000001, function () {
   echo "time is ticking...";   // this works periodically 
});

This only happens when ExtEvLoop is used and StreamSelectLoop does not have this problem.

from event-loop.

clue avatar clue commented on June 14, 2024

@my-random-username Thanks for reporting what sounds like a bug in the ExtEvLoop event loop implementation.

I agree that using a zero interval is rarely useful but may still happen in practice. As a counter measure, it looks like this is easy to work around by using a non-zero interval as suggested above.

I don't currently have access to a system with ext-ev installed, but if what you're saying is correct than I would consider this to be a (minor) defect. If anybody feels like picking this up, this sounds like a rather small fix, so PRs to address this are much appreciated! :shipit:

from event-loop.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.