This crate provides an ability to send future for execution on the runtime that may be in a different thread. Typical use case is heavily threaded application where there are synchronous callbacks, but some asynchronous tasks also need to be executed.
To get started, add the following to Cargo.toml
.
toml
side-futures = "0.1.0"
Typical usage with Tokio runtime: ```rust use tokio::task;
async fn main() { let (sender, receiver) = sidefutures::create(); task::spawn(receiver.runreceiver(task::spawn)); sender .send_future(async { // Do stuff }) .unwrap(); } ```
Typical usage with Actix runtime: ```rust
async fn main() { let (sender, receiver) = sidefutures::create(); actixrt::spawn(receiver.runreceiver(actixrt::spawn)); sender .send_future(async { // Do stuff }) .unwrap(); } ```
Feel free to create issues and send pull requests, they are highly appreciated!
Zero-Clause BSD
https://opensource.org/licenses/0BSD
https://tldrlegal.com/license/bsd-0-clause-license