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

lock_api: Mark unlock and friends unsafe. #243

Merged
merged 5 commits into from
Jun 18, 2020

Conversation

brain0
Copy link

@brain0 brain0 commented Jun 10, 2020

Methods like unlock, bump, upgrade, downgrade and similar all assume that a certain kind of lock is being held. Since the wrapper mutex and guard types in the lock_api crate guarantee that these APIs are always used correctly, these methods are made unsafe to allow implementers to skip checks for these conditions. This allows sound and efficient implementations of these traits.

I hope I did not forget any methods or screw up any comments.

@brain0
Copy link
Author

brain0 commented Jun 10, 2020

This fixes #242.

lock_api/src/mutex.rs Show resolved Hide resolved
lock_api/src/remutex.rs Show resolved Hide resolved
@Amanieu
Copy link
Owner

Amanieu commented Jun 17, 2020

@brain0 Are you still working on this? Could you please address my review comments so that I can merge this.

@brain0
Copy link
Author

brain0 commented Jun 17, 2020

Yes, sorry, I'll take care of it

@brain0
Copy link
Author

brain0 commented Jun 17, 2020

There is a new conflict, would you prefer this to be solved via merge or rebase?

@brain0
Copy link
Author

brain0 commented Jun 17, 2020

I solved the conflict with a merge to simplify review. If you prefer I rebase it, I can still do that.

@Amanieu
Copy link
Owner

Amanieu commented Jun 17, 2020

A rebase is usually the preferred way to resolve conflicts.

Thomas Bächler added 5 commits June 17, 2020 23:07
Unlocking a Mutex that you do not hold is likely to cause undefined behavior. If unlock()
is a safe method, then it likely impossible to provide a sound and efficient implemention
of the method. Since this API is usually only called by the lock_api Mutex structs, this
change should be invisible to the users, but clarifies what guarantees implementers must make.
@brain0
Copy link
Author

brain0 commented Jun 17, 2020

A rebase is usually the preferred way to resolve conflicts.

Okay, done.

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