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

[r2r] Use futures_timer crate and fix unstable tests #1511

Merged
merged 5 commits into from
Oct 28, 2022
Merged

Conversation

sergeyboyko0791
Copy link

  • Remove TimedMutexGuard as it's not used anymore

@sergeyboyko0791 sergeyboyko0791 changed the title [wip] Use futures_timer crate [r2r] Use futures_timer crate and fix unstable tests Oct 27, 2022
@sergeyboyko0791 sergeyboyko0791 requested review from artemii235, laruh, borngraced and onur-ozkan and removed request for laruh October 27, 2022 11:02
@sergeyboyko0791
Copy link
Author

Initially, I thought that the abortable_system tests are unstable due to the Timer implementation, so I found an alternative to its implementation. futures_timer seems to fit our purposes - it doesn't require to be involved over tokio runtime, so it can be used with local runtime block_on(Timer::sleep(1.)).

Also I figured out that TimedMutexGuard is not used, so I removed it. Anyway, it can be replaced by mutex.lock().timeout(1.).await instead of using custom mutex.

@sergeyboyko0791 sergeyboyko0791 self-assigned this Oct 27, 2022
artemii235
artemii235 previously approved these changes Oct 27, 2022
Copy link
Member

@artemii235 artemii235 left a comment

Choose a reason for hiding this comment

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

It's always nice to remove some old over-complicated code 🙂

Copy link
Member

@borngraced borngraced left a comment

Choose a reason for hiding this comment

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

Looks nice and great work.
Just a question

Comment on lines 27 to 29
pub fn sleep_ms(ms: u32) -> Timer {
let seconds = gstuff::duration_to_float(Duration::from_millis(ms as u64));
Timer {
till_utc: now_float() + seconds,
delay: Delay::new(Duration::from_millis(ms as u64)),
Copy link
Member

Choose a reason for hiding this comment

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

Why is sleep_ms param not u64 by default instead of requesting for u32 and then casting to u64?

Copy link
Author

@sergeyboyko0791 sergeyboyko0791 Oct 27, 2022

Choose a reason for hiding this comment

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

That's a good question! I don't know actually, but I think it's worth to change to u64

Copy link
Member

Choose a reason for hiding this comment

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

ok good thanks 👌

Copy link
Member

@onur-ozkan onur-ozkan left a comment

Choose a reason for hiding this comment

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

Good point! LGTM

@artemii235 artemii235 merged commit 14b145d into dev Oct 28, 2022
@artemii235 artemii235 deleted the use-futures-timer branch October 28, 2022 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix executor::abortable_system tests that are unstable on MacOS CI
4 participants