stop-cigarette 0.1.0

First-wins cooperative STOP signals with immutable reasons and shared propagation
Documentation
  • Coverage
  • 100%
    22 out of 22 items documented1 out of 18 items with examples
  • Size
  • Source code size: 13.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 334.1 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • hidenoriuehara-art

stop-cigarette

stop-cigarette is a dependency-free Rust library for cooperative, first-wins STOP signals.

The Cocoshiga STOP principle

This crate gives a concrete meaning to STOP のココシガの理:

A valid STOP is preserved where it happens, propagated to every holder, and never overwritten by a later voice.

The first valid request records who stopped the work and why. Every clone sees the same immutable record. Later requests are idempotent and return the original record instead of changing history.

Example

use stop_cigarette::{CocoshigaStop, StopStatus};

let signal = CocoshigaStop::new();
let worker_signal = signal.clone();

assert!(worker_signal.checkpoint().is_ok());

let outcome = signal.request_stop("operator", "unsafe condition")?;
assert_eq!(outcome.status(), StopStatus::StoppedNow);

let stopped = worker_signal.checkpoint().unwrap_err();
assert_eq!(stopped.record().actor(), "operator");

# Ok::<(), stop_cigarette::RequestError>(())

Guarantees

  • First valid STOP wins, even across competing threads.
  • The actor and reason are immutable after stopping.
  • Clones share one signal and one stop record.
  • Repeated requests are safe and report AlreadyStopped.
  • Invalid empty actors or reasons never mutate the signal.
  • The implementation uses only the Rust standard library.

This is a cooperative signal: code must call checkpoint or is_stopped. It does not forcibly terminate threads or processes.

License

MIT