Module borrow
Expand description
This module contains types that can be used to implement atomic borrowing.
AtomicBorrow is used to borrow immutably.
AtomicBorrow::try_new locks an atomic in such a way
that it can be locked immutably again but not mutably.
It fails if already borrowed mutably.
AtomicBorrowMut is used to borrow mutably.
AtomicBorrowMut::try_new locks an atomic in such a way
that it cannot be locked again.
It fails if already borrowed.
Both types use AtomicIsize as a locking atomic.
Where 0 means “not borrowed”,
immutable borrows are represented by positive values
and mutable borrows are represented by negative values.
Structs§
- Atomic
Borrow - Encapsulates shared borrowing state.
- Atomic
Borrow Mut - Encapsulates exclusive borrowing state.
Functions§
- check_
read_ refs_ count - Returns true if there are too many read refs.
- check_
write_ refs_ count - Returns true if there are too many write refs.
- clone_
borrow - Clones immutable borrow of specified lock. This function MUST be called only when lock is already borrowed immutably.
- clone_
borrow_ mut - Clones mutable borrow of specified lock. This function MUST be called only when lock is already borrowed mutably.
- is_
borrowed - Returns true if specified lock value is borrowed.
- is_
reading - Returns true if specified lock value is borrowed immutably.
- is_
writing - Returns true if specified lock value is borrowed mutably.
- new_
lock - Create atomic borrow lock. Initially not borrowed.
- release_
borrow - Releases immutable borrow of specified lock. This function MUST be called only when lock is borrowed immutably. This function MUST be called only once for each succefful borrow and borrow clone.
- release_
borrow_ mut - Releases mutable borrow of specified lock. This function MUST be called only when lock is borrowed mutably. This function MUST be called only once for each succefful borrow and borrow clone.
- try_
borrow - Attempts to borrow specified lock immutably.
- try_
borrow_ mut - Attempts to borrow specified lock mutably.
Type Aliases§
- Lock
- Lock type used by [
AtomicCell].