IRQ-driven code?

Hello all,
I'm wondering what the best way to do this in Rust is. I have a disk controller that I send commands to and the controller signals an interrupt when its sent back a response. I'd like my function to be callable, but not fully return, until its received some kind of response via an interrupt. Right now I do this through a stack-allocated queue of bools, and I loope endlessly on it until I'm able to dequeue something, and halt the processor while I wait. But I doubt that this is the "right" way to do it. I've got a task executor and async/await works, but I find that, if I call an async function but I don't await it, it never executes. So what's the right way to do this? What am I missing?

To implement something like this with async/await, you would need to implement some mechanism for a wakeup to be sent to the runtime when the interrupt arrives.

That's right, all that calling an async fn does it create a Future representing an execution of that function, it does not actually run any of the code in the function.

You have to either .await the returned future, or call Future::poll on the future in order to have it actually execute. If you cannot just .await in your code, your runtime might have something like a spawn function that will do this for you (running the future as a new task in the background). You could also try to use the combinators from the futures or futures-intrusive crate, which allow selecting on multiple futures or combining their results in other ways.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.