A synchronization primitive that allows multiple threads to wait until the event is signalled.
Once an event is signalled it can be reset and reused.
Example
use std::sync::Event;
use std::thread::spawn;
let ev = Event::new();
let text: &[u8];
let t = spawn(|&ev, &text| {
text = "Hello, world!";
ev.set();
});
ev.wait();
assert_eq!(text, "Hello, world!");
t.join().unwrap();
Run this example
Fields
Methods
impl Event { ... }
-
fn new() -> Event
Create a new event in an unset state
-
fn new_set() -> Event
Create a new event in a set state
-
fn set(self: &mut Event)
Signals the event, waking up all threads that are waiting on it.
-
fn reset(self: &mut Event)
Resets the event, so that it can be waited on and signalled again.
If event is not in set state, this is a no-op.
-
Checks if the event is signalled.
-
fn wait(self: &mut Event)
Waits for the event to be signalled.