Crate refcell_lock_api

Source
Expand description

§cell-lock-api

An single-threaded implementation of lock_api using a RefCell.

This is primarily intended to allow abstracting over single-threaded and multi-threaded code.

§Example

use cell_lock_api::CellRwLock;
fn main() {
    let lock = CellRwLock::new(vec![7i32]);
    {
        let guard = lock.read();
        assert_eq!(*guard, vec![7]);
    }
    {
        let mut guard = lock.write();
        guard.push(18);
        guard.push(19);
    }
    assert_eq!(lock.into_inner(), vec![7, 18, 19])
}

Modules§

raw
The actual implementation of lock_api::RawRwLock based on a RefCell.

Type Aliases§

CellMutex
A single-threaded lock_api::Mutex using a RefCell internally.
CellRwLock
A single-threaded lock_api::RwLock using a RefCell internally.