Crates.io | thread-waker |
lib.rs | thread-waker |
version | 1.1.0 |
source | src |
created_at | 2024-07-27 09:21:01.127527 |
updated_at | 2024-08-24 00:46:23.549405 |
description | Waker implementation using current thread token |
homepage | |
repository | https://github.com/DoumanAsh/thread-waker |
max_upload_size | |
id | 1317131 |
size | 6,464 |
Waker implementation using current thread token.
This is useful to work with futures without actually employing runtime
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!");