Giter VIP home page Giter VIP logo

tokio-timerfd's Introduction

tokio-timerfd

Linux timerfd for Tokio.

This crates provides tokio-timer-like API on top of timerfd. timerfd is a Linux-specific API providing timer notifications as file descriptor read events.

The advantage of timerfd is that it has more granularity than epoll_wait(), which only provides 1 millisecond timeouts. timerfd API allows for nanosecond precision, but precise timing of the wakeup is not guaranteed on a normal multitasking system.

tokio-timerfd's People

Contributors

karlek avatar polachok avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

tokio-timerfd's Issues

New release?

The latest changes to this crate don't appear to be present in the crates.io version, is there a plan to tag a new version?

rename constructors of `Interval` to more explicit names

Hello this is me again
I was considering to add so PS to my previoous issue and then though it would be better on a different topic.

the current constructors of Interval are at the moment

  • Interval::new - initialize with a duration and a start instant
  • Interval::new_interval - with duration and current instant as start instant. The name isn't much clear but redundant with its struct name

what about renaming the constructors to:

  • Interval::new(Duration) - initialize with a duration and current instant as start instant.
    Having new with only the duration argument makes it more similar to other interval implementations (egg from tokio or std)
  • Interval::at(Instant, Duration) or Interval::starting or Interval::new_starting - initialize with a duration and a start instant.
    Since this feature is less common in other implementations, this constructor has a specific name

As a user I think it could be more intuitive and comfortable, what do you think ?

what about implementing `Future<Result<(), IoError>>` for `Interval`

Hello there
Thank you very much for featuring timerfd to tokio, it saved my realtime applications in etherage

At the moment, tokio_timerfd::Interval can only be used as an async iterator (or close to it, since rust truly supports async iterators) through the trait Stream, however it does not bring much more than a mere Future

  • no nice syntax using stream
  • more complex call to the timer

From a user point of view, using Interval as a Stream leads to a weird line like this

let interval = Interval::new_interval(...);
interval.next().await.unwrap()?;

as a Future it could be more straight forward

let interval = Interval::new_interval(...);
interval.await?;

Looking at the current implementation of Stream, it looks like Future could be implemented using the exact same code. Do you think an impl Future could be added mirroring Stream (or vice-versa) ?

Updating to Tokio 1.x.y

Would you be willing to update this to Tokio 1.x.y? There's a simple implementation here, but it's not released as a crate.

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.