#interrupt #signals #disable #signal #without #no-alloc

no-std interrupt-mutex

A mutex for sharing data with interrupt handlers or signal handlers

1 unstable release

0.1.0 Oct 8, 2023

#1035 in Unix APIs

Download history 24/week @ 2024-07-22 147/week @ 2024-07-29 125/week @ 2024-08-05 103/week @ 2024-08-12 171/week @ 2024-08-19 80/week @ 2024-08-26 47/week @ 2024-09-02 88/week @ 2024-09-09 270/week @ 2024-09-16 27/week @ 2024-09-23 66/week @ 2024-09-30 72/week @ 2024-10-07 12/week @ 2024-10-14 84/week @ 2024-10-21 29/week @ 2024-10-28 124/week @ 2024-11-04

252 downloads per month
Used in 2 crates (via hermit-sync)

MIT/Apache

9KB
51 lines

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.

Dependencies

~2MB
~38K SLoC