Expand description

This module defines types which are thread safe if cfg!(parallel_compiler) is true.

Lrc is an alias of Arc if cfg!(parallel_compiler) is true, Rc otherwise.

Lock is a mutex. It internally uses parking_lot::Mutex if cfg!(parallel_compiler) is true, RefCell otherwise.

RwLock is a read-write lock. It internally uses parking_lot::RwLock if cfg!(parallel_compiler) is true, RefCell otherwise.

MTLock is a mutex which disappears if cfg!(parallel_compiler) is false.

MTRef is an immutable reference if cfg!(parallel_compiler), and a mutable reference otherwise.

rustc_erase_owner! erases an OwningRef owner into Erased or Erased + Send + Sync depending on the value of cfg!(parallel_compiler).

Re-exports§

  • pub use std::sync::atomic::Ordering::SeqCst;

Structs§

  • A boolean type which can be safely shared between threads.
  • An integer type which can be safely shared between threads.
  • An integer type which can be safely shared between threads.
  • An integer type which can be safely shared between threads.
  • A thread-safe reference-counting pointer. ‘Arc’ stands for ‘Atomically Reference Counted’.
  • Weak is a version of Arc that holds a non-owning reference to the managed allocation. The allocation is accessed by calling upgrade on the Weak pointer, which returns an Option<Arc<T>>.
  • Holds worker-locals values for each thread in a thread pool. You can only access the worker local value through the Deref impl on the thread pool it was constructed on. It will panic otherwise

Enums§

Traits§

  • Parallel version of the standard iterator trait.
  • Types that can be transferred across thread boundaries.
  • Types for which it is safe to share references between threads.

Functions§

  • Takes two closures and potentially runs them in parallel. It returns a pair of the results from those closures.
  • Create a “fork-join” scope s and invokes the closure with a reference to s. This closure can then spawn asynchronous tasks into s. Those tasks may run asynchronously with respect to the closure; they may themselves spawn additional tasks into s. When the closure returns, it will block until all tasks that have been spawned into s complete.

Type Aliases§

  • An RAII implementation of a “scoped lock” of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.
  • An RAII mutex guard returned by MutexGuard::map, which can point to a subfield of the protected data.
  • An RAII read lock guard returned by RwLockReadGuard::map, which can point to a subfield of the protected data.
  • An RAII write lock guard returned by RwLockWriteGuard::map, which can point to a subfield of the protected data.
  • RAII structure used to release the shared read access of a lock when dropped.
  • RAII structure used to release the exclusive write access of a lock when dropped.