interrupt-mutex

Crates.iointerrupt-mutex
lib.rsinterrupt-mutex
version0.1.0
sourcesrc
created_at2023-10-08 14:53:43.841884
updated_at2023-10-08 14:53:43.841884
descriptionA mutex for sharing data with interrupt handlers or signal handlers.
homepage
repositoryhttps://github.com/mkroening/interrupt-mutex
max_upload_size
id997179
size21,245
Martin Kröning (mkroening)

documentation

README

interrupt-mutex

Crates.io docs.rs CI

A mutex for sharing data with interrupt handlers or signal handlers.

// Make a mutex of your choice into an `InterruptMutex`.
type InterruptMutex<T> = interrupt_mutex::InterruptMutex<parking_lot::RawMutex, T>;

static X: InterruptMutex<Vec<i32>> = InterruptMutex::new(Vec::new());

fn interrupt_handler() {
    X.lock().push(1);
}

let v = X.lock();
// Raise an interrupt
raise_interrupt();
assert_eq!(*v, vec![]);
drop(v);

// The interrupt handler runs

let v = X.lock();
assert_eq!(*v, vec![1]);
drop(v);

For API documentation, see the docs.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 1

cargo fmt