GithubHelp home page GithubHelp logo

timer-stop logic about libuev HOT 3 CLOSED

troglobit avatar troglobit commented on May 31, 2024
timer-stop logic

from libuev.

Comments (3)

troglobit avatar troglobit commented on May 31, 2024

That is intended behavior, not really well documented though. Setting timeout to zero disarms the timer. So for a periodic timer you have to set the initial delay as well.

The uev_timer_init() function calls uev_timer_set() (below):

libuev/src/timer.c

Lines 93 to 105 in a334d23

/**
* Reset a timer
* @param w Watcher to reset
* @param timeout Timeout in milliseconds before @param cb is called, zero disarms timer
* @param period For periodic timers this is the period time that @param timeout is reset to
*
* Note, the @param timeout value must be non-zero. Setting it to zero
* will disarm the timer. This is the underlying Linux function @func
* timerfd_settimer() which has this behavior.
*
* @return POSIX OK(0) or non-zero with @param errno set on error.
*/
int uev_timer_set(uev_t *w, int timeout, int period)

from libuev.

M1cha avatar M1cha commented on May 31, 2024

That part is not true though:

This is the underlying Linux function @func timerfd_settimer() which has this behavior. 

https://linux.die.net/man/2/timerfd_settime

Setting either field of new_value.it_value to a nonzero value arms the timer. Setting both fields of new_value.it_value to zero disarms the timer.

from libuev.

M1cha avatar M1cha commented on May 31, 2024

forget what I said. I didn't read properly and thought they were talking about "both" in the sense of "it_interval" and "it_value"

from libuev.

Related Issues (19)

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.