Module borrow

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§

AtomicBorrow
Encapsulates shared borrowing state.
AtomicBorrowMut
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].