[][src]Module swc_common::sync

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

Lrc is an alias of either Rc or Arc.

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

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

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

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

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

Re-exports

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

Structs

AtomicBool

A boolean type which can be safely shared between threads.

AtomicUsize

An integer type which can be safely shared between threads.

Lock
Lrc

A thread-safe reference-counting pointer. 'Arc' stands for 'Atomically Reference Counted'.

MTLock
Once

A type whose inner value can be written once and then will stay read-only

OneThread

A type which only allows its inner value to be used in one thread. It will panic if it is used on multiple threads.

RwLock
SerialScope
Weak

Weak is a version of Arc that holds a non-owning reference to the managed value. The value is accessed by calling upgrade on the Weak pointer, which returns an Option<Arc<T>>.

Enums

Ordering

Atomic memory orderings

Traits

HashMapExt
ParallelIterator

Parallel version of the standard iterator trait.

Send

Types that can be transferred across thread boundaries.

Sync

Types for which it is safe to share references between threads.

Functions

assert_send
assert_send_sync_val
assert_send_val
assert_sync
join

Takes two closures and potentially runs them in parallel. It returns a pair of the results from those closures.

par_iter
scope

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.

serial_join
serial_scope

Type Definitions

LockGuard

An RAII implementation of a "scoped lock" of a mutex. When this structure is dropped (falls out of scope), the lock will be unlocked.

MTRef
MappedLockGuard

An RAII mutex guard returned by MutexGuard::map, which can point to a subfield of the protected data.

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.

MetadataRef
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.