thread-waker

Crates.iothread-waker
lib.rsthread-waker
version1.1.0
sourcesrc
created_at2024-07-27 09:21:01.127527
updated_at2024-08-24 00:46:23.549405
descriptionWaker implementation using current thread token
homepage
repositoryhttps://github.com/DoumanAsh/thread-waker
max_upload_size
id1317131
size6,464
Douman (DoumanAsh)

documentation

README

thread-waker

Rust Crates.io Documentation

Waker implementation using current thread token.

This is useful to work with futures without actually employing runtime

Usage

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!");
Commit count: 0

cargo fmt