> extern fn callback(cbdata: *Void) {
>     let data = from_cbdata(cbdata);
>     do in_stack_task {
>         // Send a message to a normal Rust task
>         data.chan.send(GoDoSomethingInARustTask);
>     }
> }

Something like this is also very important for microcontroller
interrupts - though it might not be from another language. How most
modern interrupt controllers work (for example, ARM NVIC) is by
pushing a partial C stack frame, and then calling a particular address
- which can be a void C function as the ABI is the same. In the case
of Rust, we could write a pure Rust interrupt, however it would
execute outside of the context of the normal scheduler and need to
push a message into it. Because Rust's scheduler is not preemptive, it
would not perform a task switch immediately, though the scheduler
might need some sort of special indication that someone changed its
data without it looking, so the next switch takes the new message into
account.
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to