Struct rendezvous_swap::Rendezvous
source · #[non_exhaustive]pub struct Rendezvous { /* private fields */ }
Expand description
Synchronise execution between threads.
Example: Sync thread execution
use rendezvous_swap::Rendezvous;
use std::thread;
let (mut my_rendezvous, mut their_rendezvous) = Rendezvous::new();
thread::spawn(move || {
for i in 1..5 {
println!("{i}");
their_rendezvous.wait();
}
});
for i in 1..5 {
println!("{i}");
my_rendezvous.wait();
}
This prints:
1
1
2
2
3
3
4
4
Implementations§
source§impl Rendezvous
impl Rendezvous
sourcepub fn wait(&mut self)
pub fn wait(&mut self)
Synchronize execution with other thread.
As a side-effect, memory is also synchronized.
sourcepub fn wait_inline(&mut self)
pub fn wait_inline(&mut self)
Always inlined version of Rendezvous::wait
sourcepub fn new() -> (Self, Self)
pub fn new() -> (Self, Self)
Create a linked pair of Rendezvous