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 version detection for stabilized atomics and checked_add #133

Merged
merged 1 commit into from
Apr 14, 2019

Conversation

faern
Copy link
Collaborator

@faern faern commented Apr 13, 2019

Automatically detecting Rust >= 1.34 and make good use of the now stable AtomicU{8,32} types as well as Instant::checked_add.

This has been broken out from #119 since that PR is a bit large and this commit is not really related to the crate being used in libstd. We don't really know when the libstd stuff will be merged anyway, and this could be immediately useful to anyone using parking_lot on the latest stable Rust.

I'm just generally against "let's just put this in the already open PR, it'll be fine". I find it usually creates more problems than it solves.

use parking_lot_core::{self, SpinWait, DEFAULT_PARK_TOKEN, DEFAULT_UNPARK_TOKEN};

#[cfg(has_sized_atomics)]
type U8 = u8;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I split the type definitions from the imports. I find this much more readable.

@Amanieu
Copy link
Owner

Amanieu commented Apr 13, 2019

bors r+

bors bot added a commit that referenced this pull request Apr 13, 2019
133: Add version detection for stabilized atomics and checked_add r=Amanieu a=faern

Automatically detecting Rust >= 1.34 and make good use of the now stable `AtomicU{8,32}` types as well as `Instant::checked_add`.

This has been broken out from #119 since that PR is a bit large and this commit is not really related to the crate being used in libstd. We don't really know when the libstd stuff will be merged anyway, and this could be immediately useful to anyone using `parking_lot` on the latest stable Rust.

I'm just generally against "let's just put this in the already open PR, it'll be fine". I find it usually creates more problems than it solves.

Co-authored-by: Linus Färnstrand <faern@faern.net>
@bors
Copy link
Contributor

bors bot commented Apr 14, 2019

@bors bors bot merged commit 696f83f into Amanieu:master Apr 14, 2019
@faern faern deleted the auto-detect-stable-atomics branch April 14, 2019 07:33
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.

2 participants