https://github.com/nazar-pc/side-futures
Send future for execution on the runtime that may be in a different thread
https://github.com/nazar-pc/side-futures
futures send spawn
Last synced: about 1 year ago
JSON representation
Send future for execution on the runtime that may be in a different thread
- Host: GitHub
- URL: https://github.com/nazar-pc/side-futures
- Owner: nazar-pc
- License: 0bsd
- Created: 2020-03-22T21:36:14.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-12T01:07:28.000Z (about 5 years ago)
- Last Synced: 2025-04-11T02:14:21.454Z (about 1 year ago)
- Topics: futures, send, spawn
- Language: Rust
- Size: 7.81 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: copying.md
Awesome Lists containing this project
README
## Side futures
[](https://travis-ci.org/nazar-pc/side-futures)
[](https://crates.io/crates/side-futures)
[](https://docs.rs/side-futures)
[](https://github.com/nazar-pc/side-futures)
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.
## Example
To get started, add the following to `Cargo.toml`.
```toml
side-futures = "0.1.0"
```
Typical usage with Tokio runtime:
```rust
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:
```rust
#[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();
}
```
## Contribution
Feel free to create issues and send pull requests, they are highly appreciated!
## License
Zero-Clause BSD
https://opensource.org/licenses/0BSD
https://tldrlegal.com/license/bsd-0-clause-license