Module gstd::sync

source ·
Expand description

Data access synchronization objects.

These synchronization objects are similar to those in the std::sync module, but they prevent data races when dealing with multiple actors (users or programs) instead of multiple threads considered in classic synchronization objects.

The following is an overview of the available synchronization objects:

  • Mutex: The Mutual Exclusion mechanism guarantees that during execution, only a single actor can access data at any given time.
  • RwLock: Provides a mutual exclusion mechanism that allows multiple readings by different actors while allowing only one writer at the execution. In some cases, this can be more efficient than a mutex.

Structs§

  • A mutual exclusion primitive useful for protecting shared data.
  • An RAII implementation of a “scoped lock” of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.
  • The future returned by the lock method.
  • A reader-writer lock.
  • The future returned by the read method.
  • RAII structure used to release the shared read access of a lock when dropped.
  • The future returned by the write method.
  • RAII structure used to release the exclusive write access of a lock when dropped.