Crate sync_cell

Source
Expand description

A module containing easier to use thread-safe types for the creation of larger thread safe systems.

§Included Types

  • SyncCell - A replacement for std::cell::RefCell and std::cell::Cell with an easier to use API than std::sync::RwLock.
  • HeldSyncCell - A cell that maintains a previous value until the update method is called at which point any changes to the value are applied.

Structs§

HeldSyncCell
A cell that holds a value until any changes made are applied by use of the update method. Getting the value or obtaining a reference to the value in this cell will return the value immediately following the last call to update. This allows for mutably altering a value while keeping a reference for a short amount of time to the old value. This is useful when you want a method in a structure to be able to modify the structure it is being called from such as when changing the scene in a game engine.
SyncCell
A mutable memory location that can be modified safely from multiple threads. This structure is similar to std::cell::Cell or std::cell::RefCell while being thread-safe. It functions as a thin wrapper around std::sync::RwLock while assuming that poisoned locks indicate an unrecoverable error. This makes it more ergonomic to use than RwLock at the cost of some stability.