Struct extra::sync::Mutex

pub struct Mutex {
    priv sem: Sem<~[WaitQueue]>,
}

Mutexes A blocking, bounded-waiting, mutual exclusion lock with an associated FIFO condition variable.

Failure

A task which fails while holding a mutex will unlock the mutex as it unwinds.

Methods

impl Mutex

fn new() -> Mutex

Create a new mutex, with one associated condvar.

fn new_with_condvars(num_condvars: uint) -> Mutex

Create a new mutex, with a specified number of associated condvars. This will allow calling wait_on/signal_on/broadcast_on with condvar IDs between 0 and num_condvars-1. (If num_condvars is 0, lock_cond will be allowed but any operations on the condvar will fail.)

fn lock<U>(&self, blk: &fn() -> U) -> U

Run a function with ownership of the mutex.

fn lock_cond<U>(&self, blk: &fn(c: &Condvar) -> U) -> U

Run a function with ownership of the mutex and a handle to a condvar.

Trait Implementations

impl std::clone::Clone for Mutex

fn clone(&self) -> Mutex

Create a new handle to the mutex.