Skip to content

Instantly share code, notes, and snippets.

@AsafFisher

AsafFisher/mod.rs

Last active Oct 9, 2020
Embed
What would you like to do?
cool
macro_rules! concurrent {
(
[ $($pass_rc:ident),* ];$($x:expr);*;
) => {
{
{
$(
let $pass_rc = Arc::new($pass_rc);
let $pass_rc = &$pass_rc.clone();
)*
std::thread::spawn(move || {
$(
$x;
)*
})
}
}
}
}
// Start the broadcasting, pass the Arc of multicast_addr and b_stopper
let handle = concurrent! {[self.multicast_addr, self.b_stopper];
broadcast(send_socket, multicast_addr,
b_stopper).unwrap();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment