Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 2 months 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 (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-12T01:07:28.000Z (over 3 years ago)
- Last Synced: 2024-10-13T18:50:49.178Z (2 months ago)
- Topics: futures, send, spawn
- Language: Rust
- Size: 7.81 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: copying.md
Awesome Lists containing this project
README
## Side futures
[![Build Status](https://img.shields.io/travis/com/nazar-pc/side-futures/master?style=flat-square)](https://travis-ci.org/nazar-pc/side-futures)
[![Crates.io](https://img.shields.io/crates/v/side-futures?style=flat-square)](https://crates.io/crates/side-futures)
[![Docs](https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square)](https://docs.rs/side-futures)
[![License](https://img.shields.io/github/license/nazar-pc/side-futures?style=flat-square)](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 BSDhttps://opensource.org/licenses/0BSD
https://tldrlegal.com/license/bsd-0-clause-license