Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add interval api. #41

Merged
5 commits merged into from
Nov 28, 2020
Merged

Add interval api. #41

5 commits merged into from
Nov 28, 2020

Conversation

dvc94ch
Copy link
Contributor

@dvc94ch dvc94ch commented Nov 20, 2020

Based on #35, needed to use async-io in more places in libp2p.

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Nov 20, 2020

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Nov 23, 2020

@stjepang any comments? It's currently blocking a PR of mine.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for implementing this! The PR looks good, I would just request the following changes:

  1. Implement poll() by calling poll_next(). Treat a regular timer (at()/after()) as a stream (interval_at()) with a period of infinity.
  2. Add a unit test to tests/timer.rs

@dvc94ch

This comment has been minimized.

@dvc94ch dvc94ch requested a review from a user November 26, 2020 12:50
@ghost
Copy link

ghost commented Nov 26, 2020

Why is the first tick of a timer constructed by interval() immediate? setInterval() in javscript and Ticker in Go don't fire immediately, so I'm inclined to follow the same behavior here...

@dvc94ch

This comment has been minimized.

@dvc94ch
Copy link
Contributor Author

dvc94ch commented Nov 27, 2020

I think I agree, you can easily get the first tick with Timer::interval_at(Instant::now(), period)

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ghost ghost merged commit 75316e2 into smol-rs:master Nov 28, 2020
@dvc94ch
Copy link
Contributor Author

dvc94ch commented Nov 28, 2020

Can you release 1.3.0? Then I can update my PR's to libp2p.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant