fix(api)!: fix safety issue with raw::Mutex
locking API
#17
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces breaking changes to fix a safety issue with the current API. Currently, users may invoke undefined behavior with a safe and allowed call of
core::mem::forget
over a instance ofraw::MutexGuard
. See the example bellow for one possible order of events that will trigger UB under the current API. From this version onwards, users don't have any access to araw::MutexGuard
instance. To access the mutex's protected data, user's will get a&mut T
as the closure parameter for locking operations underraw::Mutex
. Noraw
locking API will return a guard instance.BREAKING
raw::MutexGuard
type,raw::Mutex::lock
andraw::Mutex::try_lock
methodsraw::Mutex::lock_with
method toraw::Mutex::lock_then
raw::Mutex::try_lock_with
method toraw::Mutex::try_lock_then
raw::Mutex::lock_with_local
method toraw::Mutex::lock_with_local_then
raw::Mutex::lock_with_local_unchecked
method toraw::Mutex::lock_with_local_then_unchecked
raw::Mutex::try_lock_with_local
method toraw::Mutex::try_lock_with_local_then
raw::Mutex::try_lock_with_local_unchecked
method toraw::Mutex::try_lock_with_local_then_unchecked
barging::Mutex::lock_with
method tobarging::Mutex::lock_then
barging::Mutex::try_lock_with
method tobarging::Mutex::try_lock_then
raw::Mutex
'sthen
(previouswith
) locking methods fromMutexGuard
to&mut T
Added
raw::Mutex::lock_with_then
methodraw::Mutex::try_lock_with_then
methodUndefined behavior with current API: