Module bones_ecs::atomic::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§

Functions§

  • Returns true if there are too many read refs.
  • Returns true if there are too many write refs.
  • Clones immutable borrow of specified lock. This function MUST be called only when lock is already borrowed immutably.
  • Clones mutable borrow of specified lock. This function MUST be called only when lock is already borrowed mutably.
  • Returns true if specified lock value is borrowed.
  • Returns true if specified lock value is borrowed immutably.
  • Returns true if specified lock value is borrowed mutably.
  • Create atomic borrow lock. Initially not borrowed.
  • 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.
  • 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.
  • Attempts to borrow specified lock immutably.
  • Attempts to borrow specified lock mutably.

Type Aliases§

  • Lock type used by [AtomicCell].