std1.0.0-beta-7 SafeC docs

std :: thread

Struct std::Mutex

#include <std/thread.h> source

generic<T: Send> struct Mutex { }

A T shared between threads, reachable only while locked. Moving a Mutex after locking it is not allowed (guards point at it).

Methods

§static struct Mutex<T> new(T value)source · definition
§struct MutexGuard<T> lock() constsource · definition

Blocks until this thread holds the lock. The guard is the only way to the value; dropping it unlocks. Don't lock twice on one thread.

§T into_inner() consumesource · definition

The value back; the Mutex is gone (no guard may be alive).

§void drop()source · definition

drops the value, destroys the lock