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 Support for creating the locking primitives in a const context on stable Rust #217

Merged
merged 3 commits into from
Feb 19, 2020

Conversation

CryZe
Copy link
Contributor

@CryZe CryZe commented Feb 18, 2020

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.

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.
@CryZe
Copy link
Contributor Author

CryZe commented Feb 18, 2020

This is a rough initial implementation. I'm not sure if the helpers in parking_lot are something that we would want as well. I can remove them if not.

Copy link
Owner

@Amanieu Amanieu left a 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_* to const_* 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_*`.
@CryZe CryZe requested a review from Amanieu February 19, 2020 10:31
@Amanieu
Copy link
Owner

Amanieu commented Feb 19, 2020

bors r+

bors bot added a commit that referenced this pull request Feb 19, 2020
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 <christopher.serr@gmail.com>
@bors
Copy link
Contributor

bors bot commented Feb 19, 2020

@bors bors bot merged commit b62d1f5 into Amanieu:master Feb 19, 2020
@thomcc
Copy link
Contributor

thomcc commented Mar 17, 2020

Any chance this could get cut in a release? I could probably deprecate https://crates.io/crates/static_locks if it were.

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.

3 participants