Crates.io | interrupt-ref-cell |
lib.rs | interrupt-ref-cell |
version | 0.1.1 |
source | src |
created_at | 2023-10-08 13:36:37.946507 |
updated_at | 2023-10-11 08:44:57.054301 |
description | A `RefCell` for sharing data with interrupt handlers or signal handlers on the same thread. |
homepage | |
repository | https://github.com/mkroening/interrupt-ref-cell |
max_upload_size | |
id | 997124 |
size | 51,058 |
A RefCell
for sharing data with interrupt handlers or signal handlers on the same thread.
use interrupt_ref_cell::{InterruptRefCell, LocalKeyExt};
thread_local! {
static X: InterruptRefCell<Vec<i32>> = InterruptRefCell::new(Vec::new());
}
fn interrupt_handler() {
X.with_borrow_mut(|v| v.push(1));
}
X.with_borrow(|v| {
// Raise an interrupt
raise_interrupt();
assert_eq!(*v, vec![]);
});
// The interrupt handler runs
X.with_borrow(|v| assert_eq!(*v, vec![1]));
For API documentation, see the docs.
Licensed under either of
at your option.
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.