GithubHelp home page GithubHelp logo

Comments (3)

kelunik avatar kelunik commented on September 26, 2024

Hey @Tiadem, welcome! As you have observed, timeout doesn't work with sleep. That's because it's a blocking function that blocks the whole process. In fact, timeout doesn't cancel any operation either, it's just a way to timeout waiting for a particular promise to resolve.

Try adding another repeat timer that prints some dots periodically and observe the difference with using sleep vs. delay.

from amp.

Tiadem avatar Tiadem commented on September 26, 2024

Hey @kelunik thanks for support, you guys are doing great job for PHP 😄 . Perhaps i have to dive more into understanding those async, concurrency concepts.At the beginning i assumed that timeout function starts counting from Loop's defer function call till resolve function call. If that process will exceed timeout then exception will be thrown immediately and stops further promise resolving as it's catched. But now i suppose that regular sleep function stops everything including time counting between defer call and resolve call. Is there any example from standard PHP operations that works with timeout or just those Loop delay and repeat functions?

from amp.

kelunik avatar kelunik commented on September 26, 2024

@Tiadem Thanks! sleep doesn't stop the time counting, but it simply blocks the defer callback from executing or rather the event loop checking whether it should execute anything else. Standard PHP functions aren't compatible with the event loop without special care, e.g. streams need to be set to non-blocking mode. That's why we've built to many packages around I/O implementing things in a non-blocking and compatible way.

from amp.

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.