text_fonts

module std::syncsource

What tasks share (LANGUAGE_SPEC.md section 5.6).

The types here declare Shared, a lang item: their fields change through a '&', since each synchronizes its own changes, and the compiler lets every task of a scope use them. Atomic values, a mutex whose guard is disposed to unlock it, and a channel moving values from task to task. The externs are the runtime's atomic operations and futex waits (the interpreter runs them over its cooperative tasks).

interface Sharedsource

exp interface Shared

Values whose changes synchronize themselves, which any task may use.

Implemented by

interface AtomicValuesource

exp interface AtomicValue

What an Atomic holds: the integer types and bool, which satisfy it with no marker (a lang item).

type Atomicsource

exp type Atomic<T: AtomicValue> : Shared = struct

An integer or bool read and changed whole, each operation sequentially consistent.

Functions

fn Atomic::fromsource

exp fn Atomic::from(value: T) -> Atomic<T>

fn loadsource

exp fn load<T: AtomicValue>(self a: &Atomic<T>) -> T

fn storesource

exp fn store<T: AtomicValue>(self a: &Atomic<T>, value: T)

fn exchangesource

exp fn exchange<T: AtomicValue>(self a: &Atomic<T>, value: T) -> T

Stores the value and gives the one before.

fn compare_exchangesource

exp fn compare_exchange<T: AtomicValue>(self a: &Atomic<T>, expected: T, desired: T) -> bool

Stores desired if the value is expected, and says whether it was.

fn addsource

exp fn add(self a: &Atomic<u8>, amount: u8) -> u8

Adds the amount, wrapping, and gives the value before.

fn addsource

exp fn add(self a: &Atomic<u16>, amount: u16) -> u16

fn addsource

exp fn add(self a: &Atomic<u32>, amount: u32) -> u32

fn addsource

exp fn add(self a: &Atomic<u64>, amount: u64) -> u64

fn addsource

exp fn add(self a: &Atomic<i8>, amount: i8) -> i8

fn addsource

exp fn add(self a: &Atomic<i16>, amount: i16) -> i16

fn addsource

exp fn add(self a: &Atomic<i32>, amount: i32) -> i32

fn addsource

exp fn add(self a: &Atomic<i64>, amount: i64) -> i64

type Mutexsource

exp type Mutex<T> : Shared + Disposable if (T: Disposable) = struct

A value one task at a time reaches, through the guard lock gives. A mutex of a disposable value is disposable, disposing the value.

Functions

fn Mutex::fromsource

exp fn Mutex::from(value: T) -> Mutex<T>

fn disposesource

exp fn dispose<T: Disposable>(self m: &var Mutex<T>)

type Guardsource

exp type Guard<T> : Disposable = struct

The mutex locked until the guard is disposed.

Functions

fn locksource

exp fn lock<T>(self m: &Mutex<T>) -> Guard<T>

Waits until the mutex is free and locks it.

fn valuesource

exp fn value<T>(self g: &Guard<T>) -> &var T

The locked value.

fn disposesource

exp fn dispose<T>(self g: &var Guard<T>)

Unlocks the mutex.

type Channelsource

exp type Channel<T> : Shared + Disposable if (T: Disposable) = struct

Values sent by some tasks and received by others, first in first out. A channel of disposable values is disposable, disposing those still queued.

Functions

fn Channel::emptysource

exp fn Channel::empty() -> Channel<T>

fn sendsource

exp fn send<T>(self c: &Channel<T>, item: T)

Queues the item for a receiver.

fn receivesource

exp fn receive<T>(self c: &Channel<T>) -> Option<T>

The oldest item not yet received, waiting for one; None once the channel is closed and empty.

fn try_receivesource

exp fn try_receive<T>(self c: &Channel<T>) -> Option<T>

The oldest item not yet received, or None at once when there is none.

fn closesource

exp fn close<T>(self c: &Channel<T>)

Ends the channel: receivers get what is queued, then None.

fn disposesource

exp fn dispose<T: Disposable>(self c: &var Channel<T>)

Disposes the queued items, oldest first.

fn chunkssource

exp fn chunks<T>(items: &var [T], size: u64) -> Vector<&var [T]>

The slice in pieces of at most size elements, each its own &var [T], so that tasks may each change one (section 5.6).