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

Implement loom version of parking #8

Merged
merged 5 commits into from
Oct 16, 2022
Merged

Implement loom version of parking #8

merged 5 commits into from
Oct 16, 2022

Conversation

notgull
Copy link
Member

@notgull notgull commented Oct 3, 2022

In smol-rs/event-listener#30, I implemented my own version of parking using Loom primitives. @zseri asked me to upstream it to this repository. This PR adds a new "loom" feature that, when the Rust --cfg loom flag is enabled, reimplements parking using Loom primitives.

Since loom doesn't support timeouts there's not much that I can really do in terms of testing, so I just added a simple smoke test.

Cargo.toml Show resolved Hide resolved
@notgull
Copy link
Member Author

notgull commented Oct 3, 2022

The CI isn't running for some reason, let me try closing and reopening.

@notgull notgull closed this Oct 3, 2022
@notgull notgull reopened this Oct 3, 2022
@fogti
Copy link
Member

fogti commented Oct 3, 2022

don't worry CI auto-disabled due to infrequent usage

@fogti
Copy link
Member

fogti commented Oct 3, 2022

Should work after rebasing this branch against master

src/lib.rs Outdated
use std::cell::Cell;
use std::fmt;
use std::marker::PhantomData;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering::SeqCst;
use std::sync::{Arc, Condvar, Mutex};
use std::time::{Duration, Instant};
Copy link
Member

Choose a reason for hiding this comment

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

Are these used when #[cfg(loom)] is active?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. I import either the std::sync or loom::sync module based on the configuration, and then I import synchronization primitives straight from the resulting sync module.

Copy link
Member

Choose a reason for hiding this comment

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

nah, I'm talking about std::time::* stuff...

Copy link
Member Author

Choose a reason for hiding this comment

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

Duration is used but Instant is not. This should now be fixed.

@notgull
Copy link
Member Author

notgull commented Oct 16, 2022

@smol-rs/admins Any blockers to this being merged?

@notgull notgull merged commit 7e13f26 into master Oct 16, 2022
@notgull notgull deleted the loom branch October 16, 2022 15:56
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.

3 participants