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.
Type | Serial version | Parallel version |
---|---|---|
Lrc<T> | rc::Rc<T> | sync::Arc<T> |
Weak<T> | rc::Weak<T> | sync::Weak<T> |
LRef<'a, T> 1 | &'a mut T | &'a T |
AtomicBool | Cell<bool> | atomic::AtomicBool |
AtomicU32 | Cell<u32> | atomic::AtomicU32 |
AtomicU64 | Cell<u64> | atomic::AtomicU64 |
AtomicUsize | Cell<usize> | atomic::AtomicUsize |
Lock<T> | RefCell<T> | RefCell<T> or |
parking_lot::Mutex<T> | ||
RwLock<T> | RefCell<T> | parking_lot::RwLock<T> |
MTLock<T> 2 | T | Lock<T> |
MTLockRef<'a, T> 1 | &'a mut MTLock<T> | &'a MTLock<T> |
ParallelIterator | Iterator | rayon::iter::ParallelIterator |
Re-exports§
Modules§
- freeze 🔒
- lock 🔒
- This module implements a lock which only uses synchronization if
might_be_dyn_thread_safe
is true. It implementsDynSend
andDynSync
instead of the typicalSend
andSync
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§
- Append
Only Index Vec - Append
Only Vec - Atomic
Bool - A boolean type which can be safely shared between threads.
- Atomic
U32 - An integer type which can be safely shared between threads.
- Atomic
U64 - An integer type which can be safely shared between threads.
- Atomic
Usize - An integer type which can be safely shared between threads.
- Cache
Aligned - Freeze
Lock - A type which allows mutation using a lock until the value is frozen and can be accessed lock-free.
- Freeze
Read Guard - A guard holding shared access to a
FreezeLock
which is in a locked state or frozen. - Freeze
Write Guard - A guard holding mutable access to a
FreezeLock
which is in a locked state or frozen. - Lrc
- A thread-safe reference-counting pointer. ‘Arc’ stands for ‘Atomically Reference Counted’.
- MTLock
- Once
Lock - A synchronization primitive which can nominally be written to only once.
- Registry
- Represents a list of threads which can access worker locals.
- RwLock
- Weak
Weak
is a version ofArc
that holds a non-owning reference to the managed allocation.- Worker
Local - Holds worker local values for each possible thread in a registry. You can only access the
worker local value through the
Deref
impl on the registry associated with the thread it was created on. It will panic otherwise.
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§
- Hash
MapExt - Send
- Types that can be transferred across thread boundaries.
- Sync
- Types for which it is safe to share references between threads.
Functions§
- is_
dyn_ thread_ safe - join
- par_
for_ each_ in - par_map
- parallel_
guard - This gives access to a fresh parallel guard in the closure and will unwind any panics caught in it after the closure returns.
- scope
- set_
dyn_ thread_ safe_ mode - try_
par_ for_ each_ in
Type Aliases§
- LRef
- MTLock
Ref - Mapped
Lock Guard - An RAII mutex guard returned by
MutexGuard::map
, which can point to a subfield of the protected data. - Mapped
Read Guard - An RAII read lock guard returned by
RwLockReadGuard::map
, which can point to a subfield of the protected data. - Mapped
Write Guard - An RAII write lock guard returned by
RwLockWriteGuard::map
, which can point to a subfield of the protected data. - Read
Guard - RAII structure used to release the shared read access of a lock when dropped.
- Write
Guard - RAII structure used to release the exclusive write access of a lock when dropped.