-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
We definitely want to start using interrupts at some point. It's trivial to simply put a function into the interrupt table, but that function then has neither state nor a way to communicate with anything. I say we first figure out the way we want to use interrupts, and then solve how that can be done. So this issue is just here for the API.
Obviously closures come into mind when thinking about code that should be run when an interrupt triggers. There's several ways we could use them:
add a handler for the entire program lifetime
let a = some_owned_register;
interrupt_table.insert(id, move || a.update(|a| a.set_some_flag()));
// can never get `some_owned_register` back
// but could overwrite interrupt `id` with a new handler
add a handler that borrows parts of the surroundings
let a = &mut some_owned_register;
interrupt_table.with_interrupt(
id,
|| a.update(|a| a.set_some_flag()),
|interrupt_table| {
// code that needs that interrupt to be set
}
);
// interrupt is not set anymore, `some_owned_register` is available again
add a handler and a state object that you'll get back afterwards
interrupt_table.insert(id, some_owned_register, some_function_that_takes_a_ref_mut_register);
// code that needs that interrupt to be set
let some_owned_register = interrupt_table.remove(id).unwrap();
// got `some_owned_register` back
I don't think we need to decide on either of the three, they can work simultaneously.
Anything else in the possible design space?
Metadata
Metadata
Assignees
Labels
No labels