Skip to content

Instantly share code, notes, and snippets.

@AsafFisher
Last active October 9, 2020 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AsafFisher/aef425f59e90368a1ffcf199461546ea to your computer and use it in GitHub Desktop.
Save AsafFisher/aef425f59e90368a1ffcf199461546ea to your computer and use it in GitHub Desktop.
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