https://github.com/urholaukkarinen/notify-thread
A simple wrapper for notifying threads
https://github.com/urholaukkarinen/notify-thread
Last synced: 27 days ago
JSON representation
A simple wrapper for notifying threads
- Host: GitHub
- URL: https://github.com/urholaukkarinen/notify-thread
- Owner: urholaukkarinen
- License: mit
- Created: 2022-05-26T19:58:13.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-26T19:59:24.000Z (almost 3 years ago)
- Last Synced: 2025-02-12T12:57:24.880Z (3 months ago)
- Language: Rust
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# notify-thread
A simple wrapper for threads that allows you to notify the thread that something has happened.
```rust
fn main() {
// Spawn a new thread that waits until notified
let join_handle = easy_thread::spawn(|ctx| {
while !ctx.notified() {
println!("Looping");std::thread::sleep(std::time::Duration::from_millis(100));
}
});std::thread::sleep(std::time::Duration::from_millis(1000));
// Notify the thread
join_handle.notify();join_handle.join().unwrap();
}
```