[src]

Struct sync::Barrier

pub struct Barrier {
    // some fields omitted
}

A barrier enables multiple tasks to synchronize the beginning of some computation.

use sync::{Arc, Barrier};

let barrier = Arc::new(Barrier::new(10));
for _ in range(0, 10) {
    let c = barrier.clone();
    // The same messages will be printed together.
    // You will NOT see any interleaving.
    spawn(proc() {
        println!("before wait");
        c.wait();
        println!("after wait");
    });
}

Methods

impl Barrier

fn new(num_tasks: uint) -> Barrier

Create a new barrier that can block a given number of tasks.

fn wait(&self)

Block the current task until a certain number of tasks is waiting.