Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/doumanash/thread-waker
Rust Waker implementation using current thread token
https://github.com/doumanash/thread-waker
Last synced: 9 days ago
JSON representation
Rust Waker implementation using current thread token
- Host: GitHub
- URL: https://github.com/doumanash/thread-waker
- Owner: DoumanAsh
- License: bsl-1.0
- Created: 2024-07-27T09:12:37.000Z (3 months ago)
- Default Branch: master
- Last Pushed: 2024-08-24T00:46:20.000Z (2 months ago)
- Last Synced: 2024-10-11T14:17:23.425Z (26 days ago)
- Language: Rust
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# thread-waker
[![Rust](https://github.com/DoumanAsh/thread-waker/actions/workflows/rust.yml/badge.svg)](https://github.com/DoumanAsh/thread-waker/actions/workflows/rust.yml)
[![Crates.io](https://img.shields.io/crates/v/thread-waker.svg)](https://crates.io/crates/thread-waker)
[![Documentation](https://docs.rs/thread-waker/badge.svg)](https://docs.rs/crate/thread-waker/)Waker implementation using current thread token.
This is useful to work with futures without actually employing runtime
## Usage
```rust
use core::{time, task};
use std::thread;use thread_waker::waker;
fn my_future(waker: task::Waker) {
thread::sleep(time::Duration::from_millis(250));
waker.wake();
}let waker = waker(thread::current());
for _ in 0..4 {
let waker = waker.clone();
thread::spawn(move || my_future(waker));
thread::park();
}println!("I'm done!");
```