Crates.io | side-futures |
lib.rs | side-futures |
version | 0.1.2 |
source | src |
created_at | 2020-03-22 22:02:24.003531 |
updated_at | 2021-06-12 01:07:01.379466 |
description | Send future for execution on the runtime that may be in a different thread |
homepage | |
repository | https://github.com/nazar-pc/side-futures |
max_upload_size | |
id | 221566 |
size | 9,137 |
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
.
side-futures = "0.1.0"
Typical usage with Tokio runtime:
use tokio::task;
#[tokio::main]
async fn main() {
let (sender, receiver) = side_futures::create();
task::spawn(receiver.run_receiver(task::spawn));
sender
.send_future(async {
// Do stuff
})
.unwrap();
}
Typical usage with Actix runtime:
#[actix_rt::main]
async fn main() {
let (sender, receiver) = side_futures::create();
actix_rt::spawn(receiver.run_receiver(actix_rt::spawn));
sender
.send_future(async {
// Do stuff
})
.unwrap();
}
Feel free to create issues and send pull requests, they are highly appreciated!
Zero-Clause BSD