Skip to main content

Module sync

Module sync 

Source
Expand description

This module defines various operations and types that are implemented in one way for the serial compiler, and another way the parallel compiler.

Β§Operations

The parallel versions of operations use Rayon to execute code in parallel, while the serial versions degenerate straightforwardly to serial execution. The operations include join, parallel, par_iter, and par_for_each.

Β§Types

The parallel versions of types provide various kinds of synchronization, while the serial compiler versions do not.

The following table shows how the types are implemented internally. Except where noted otherwise, the type in column one is defined as a newtype around the type from column two or three.

TypeSerial versionParallel version
Lock<T>RefCell<T>RefCell<T> or
parking_lot::Mutex<T>
RwLock<T>parking_lot::RwLock<T>parking_lot::RwLock<T>

Re-exportsΒ§

use std::collections::HashMap; πŸ”’
use std::hash::BuildHasher; πŸ”’
use std::hash::Hash; πŸ”’
use std::hash::Hash; πŸ”’
pub use self::freeze::FreezeLock;
pub use self::freeze::FreezeReadGuard;
pub use self::freeze::FreezeWriteGuard;
pub use self::lock::Lock;
pub use self::lock::LockGuard;
pub use self::lock::Mode;
pub use self::mode::FromDyn;
pub use self::mode::check_dyn_thread_safe;
pub use self::mode::is_dyn_thread_safe;
pub use self::mode::set_dyn_thread_safe_mode;
pub use self::parallel::broadcast;
pub use self::parallel::par_fns;
pub use self::parallel::par_for_each_in;
pub use self::parallel::par_for_each_slice;
pub use self::parallel::par_join;
pub use self::parallel::par_map;
pub use self::parallel::par_range;
pub use self::parallel::parallel_guard;
pub use self::parallel::spawn;
pub use self::parallel::try_par_for_each_in;
pub use self::vec::AppendOnlyIndexVec;
pub use self::vec::AppendOnlyVec;
pub use self::worker_local::Registry;
pub use self::worker_local::WorkerLocal;
pub use crate::marker::*;

ModulesΒ§

atomic πŸ”’
Keep the conditional imports together in a submodule, so that import-sorting doesn’t split them up.
freeze πŸ”’
lock πŸ”’
This module implements a lock which only uses synchronization if might_be_dyn_thread_safe is true. It implements DynSend and DynSync instead of the typical Send and Sync traits.
mode πŸ”’
parallel πŸ”’
This module defines parallel operations that are implemented in one way for the serial compiler, and another way the parallel compiler.
vec πŸ”’
worker_local πŸ”’

StructsΒ§

CacheAligned
RwLock

ConstantsΒ§

ERROR_CHECKING πŸ”’
This makes locks panic if they are already held. It is only useful when you are running in a single thread

TraitsΒ§

HashMapExt

Type AliasesΒ§

AtomicU64
An integer type which can be safely shared between threads.
MappedReadGuard
An RAII read lock guard returned by RwLockReadGuard::map, which can point to a subfield of the protected data.
MappedWriteGuard
An RAII write lock guard returned by RwLockWriteGuard::map, which can point to a subfield of the protected data.
ReadGuard
RAII structure used to release the shared read access of a lock when dropped.
WriteGuard
RAII structure used to release the exclusive write access of a lock when dropped.