Expand description

This crate provides the WaitCell type.

A WaitCell<T> is a thread-safe cell which can only be written once while shared. Attempts to read the value before it is written cause the reading thread to block. In this way, it is like a “synchronous” Future.

Because the value can be written to only once while shared, WaitCell provides access to its value by shared reference (&T). To use this reference from multiple threads, T must be Sync.


use std::time::Duration;
use std::thread::{ sleep, spawn };
use waitcell::WaitCell;

static CELL: WaitCell<u64> = WaitCell::new();

fn main() {
    let setter = spawn(|| {

    // Prints "42".
    println!("{}", CELL.get());


waitcell is licensed under the terms of the Apache License, Version 2.0 or the MIT License.


waitcell is developed at GitLab.


A cell type containing a value which may not yet be available.