fn handle(
    receive_socket: Arc<UdpSocket>,
    send_socket: Arc<UdpSocket>,
    config: Config,
    send_addr: SocketAddrV4,
    thread_name: &str,
    brk: Arc<AtomicBool>,
) -> JoinHandle<()> {
    let thread_name_copied = String::from(thread_name);
    thread::Builder::new().name(String::from(thread_name)).spawn(move || {
        let queue = Arc::new(Mutex::new(BinaryHeap::<PacketWrapper>::new()));
        let condvar = Arc::new(Condvar::new());

        let sending = sending_part(&config, &queue, &condvar, &send_socket, send_addr,
                                   &thread_name_copied, brk.clone());
        let receiving = receiving_part(&config, &queue, &condvar, &receive_socket,
                                       &thread_name_copied, brk.clone());

        sending.join().expect(&format!("Can't join sending part for the {}", thread_name_copied));
        receiving.join().expect(&format!("Can't join receiving part for the {}", thread_name_copied));
    }).expect(&format!("Can't create thread for {}", thread_name))
}
/// Handles one part of the communication.
/// It receive packets from socket `send_socket` and resend them to `send_addr` from the `send_socket`.
Handles one part of the communication.
Handles one part of the communication .
fn handle(
    receive_socket: Arc<UdpSocket>,
    send_socket: Arc<UdpSocket>,
    config: Config,
    send_addr: SocketAddrV4,
    thread_name: &str,
    brk: Arc<AtomicBool>,
) -> JoinHandle<()> {
    let thread_name_copied = String::from(thread_name);
    thread::Builder::new().name(String::from(thread_name)).spawn(move || {
        let queue = Arc::new(Mutex::new(BinaryHeap::<PacketWrapper>::new()));
        let condvar = Arc::new(Condvar::new());
        let sending = sending_part(&config, &queue, &condvar, &send_socket, send_addr,
                                   &thread_name_copied, brk.clone());
        let receiving = receiving_part(&config, &queue, &condvar, &receive_socket,
                                       &thread_name_copied, brk.clone());
        sending.join().expect(&format!("Can't join sending part for the {}", thread_name_copied));
        receiving.join().expect(&format!("Can't join receiving part for the {}", thread_name_copied));
    }).expect(&format!("Can't create thread for {}", thread_name))
}
fn handle ( receive_socket : Arc < UdpSocket > , send_socket : Arc < UdpSocket > , config : Config , send_addr : SocketAddrV4 , thread_name : & str , brk : Arc < AtomicBool > , ) -> JoinHandle < ( ) > { let thread_name_copied = String :: from ( thread_name ) ; thread :: Builder :: new ( ) . name ( String :: from ( thread_name ) ) . spawn ( move | | { let queue = Arc :: new ( Mutex :: new ( BinaryHeap :: < PacketWrapper > :: new ( ) ) ) ; let condvar = Arc :: new ( Condvar :: new ( ) ) ; let sending = sending_part ( & config , & queue , & condvar , & send_socket , send_addr , & thread_name_copied , brk . clone ( ) ) ; let receiving = receiving_part ( & config , & queue , & condvar , & receive_socket , & thread_name_copied , brk . clone ( ) ) ; sending . join ( ) . expect ( & format ! ( " " thread_name_copied ) ) ; receiving . join ( ) . expect ( & format ! ( " " thread_name_copied ) ) ; } ) . expect ( & format ! ( " " thread_name ) ) }
Handles one part of the communication.
Handles one part of the communication .
receive_socket
Arc<UdpSocket>
send_socket
Arc<UdpSocket>
config
Config
send_addr
SocketAddrV4
thread_name
&str
brk
Arc<AtomicBool>
receive_socket
Arc<UdpSocket>
send_socket
Arc<UdpSocket>
config
Config
send_addr
SocketAddrV4
thread_name
&str
brk
Arc<AtomicBool>