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 removes previous
thread_local
'sMutex
andMutexGuard
types. Thread local nodes now need to be explicitly declared viathread_local_node!
macro, instead of the previous approach of transparently defining them. The problem with transparent thread local nodes design is that locking APIs are easy to use incorrectly and cause panics (for the safe APIs) and undefined behiavior (for theunchecked
variants). The new design requires explicit definition of static thread local node keys, and locking APIs require taking references to those static node keys, which makes a lot easier for callers to track them on source code and evaluate if they are already referenced (borrowed) within a closure scope. Operating over thread local nodes for locking is now part of theraw::Mutex
's API, instead of defining a separated type just for them. Thread local nodes are borrowed at runtime, and their borrows live up to the end o the closure scope operating over them. Seethread_local_node!
macro,LocalMutexNode
type and..._lock_with_local_...
functions documentation for more information.Breaking changes:
thread_local
module.thread_local
'sMutex
andMutexGuard
and their aliases.Added:
thread_local_node!
macro.LocalMutexNode
type.try_lock_with_local
function forraw::Mutex
.lock_with_local
function forraw::Mutex
.try_lock_with_local_unchecked
function forraw::Mutex
.lock_with_local_unchecked
function forraw::Mutex
.