single_thread_cell 0.3.0

Create a cell that can only be accessed by a single thread.
Documentation
  • Coverage
  • 52.94%
    9 out of 17 items documented0 out of 15 items with examples
  • Size
  • Source code size: 26.44 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.23 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • KunoSayo/single_thread_cell
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • KunoSayo

Introduction

This is a helper library to mark the cell as only being accessed by the owner thread.

If you access the cell from a different thread, the thread will be panicked.

Still in development, the API may change in the future.

Quick Start

use single_thread_cell::{SingleThreadCell, SingleThreadRefCell};

let cell = SingleThreadCell::new(0);
assert_eq!(cell.get(), 0);
cell.set(1);
assert_eq!(cell.get(), 1);

let ref_cell = SingleThreadRefCell::new(0);
assert_eq!(*ref_cell.borrow(), 0);
*ref_cell.borrow_mut() += 1;
assert_eq!(*ref_cell.borrow(), 1);

Related crates