single_thread_cell 0.1.0

Create a cell that can only be accessed by a single thread.
Documentation
  • Coverage
  • 42.86%
    6 out of 14 items documented0 out of 13 items with examples
  • Size
  • Source code size: 22.29 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 847.41 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 6s 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.

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);