-
Notifications
You must be signed in to change notification settings - Fork 224
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 Support for creating the locking primitives in a const context on stable Rust #217
Conversation
This new constructor allows creating mutexes, reentrant mutexes and RwLocks in a constant context on stable Rust by manually passing in the underlying raw mutex / rwlock.
This adds various helper functions to `parking_lot` that allow creating parking_lot's mutexes, reentrant mutexes, fair mutexes and RwLocks in constant contexts on stable Rust.
This is a rough initial implementation. I'm not sure if the helpers in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make two changes:
- Put
This allows creating a mutex in a constant context on stable Rust.
as a separate paragraph in the doc comments. This keeps the first line as a short summary of what the function actually does. - Rename the functions from
new_*
toconst_*
to make it clear that they are mainly useful for const initializers.
This splits the doc comments into multiple paragraphs and renames the helpers to create the locking primitives to `const_*` instead of `new_*`.
bors r+ |
217: Implement Support for creating the locking primitives in a const context on stable Rust r=Amanieu a=CryZe This adds a new constructor `const_new` to lock_api's mutexes, reentrant mutexes and RwLocks that allows creating them in a constant context on stable Rust by manually passing in the underlying raw mutex / rwlock. Additionally, various helper functions are being added to parking_lot that allow creating mutexes, reentrant mutexes, fair mutexes and RwLocks in constant contexts on stable Rust. Co-authored-by: Christopher Serr <[email protected]>
Any chance this could get cut in a release? I could probably deprecate https://crates.io/crates/static_locks if it were. |
This adds a new constructor
const_new
to lock_api's mutexes, reentrant mutexes and RwLocks that allows creating them in a constant context on stable Rust by manually passing in the underlying raw mutex / rwlock.Additionally, various helper functions are being added to parking_lot that allow creating mutexes, reentrant mutexes, fair mutexes and RwLocks in constant contexts on stable Rust.