could you please explain me this code?:

pub fn process_reads<K: Kmer + Sync + Send, P: AsRef<Path> + Debug>(
    reader: fastq::Reader<io::BufReader<File>>,
    index: &Pseudoaligner<K>,
    outdir: P,
    num_threads: usize,
) -> Result<(), Error> {
    info!("Done Reading index");
    info!("Starting Multi-threaded Mapping");
    info!("Output directory: {:?}", outdir);

    let (tx, rx) = mpsc::sync_channel(num_threads);
    let atomic_reader = Arc::new(Mutex::new(reader.records()));

    info!("Spawning {} threads for Mapping.\n", num_threads);
    scope(|scope| {
        for _ in 0..num_threads {
            let tx = tx.clone();
            let reader = Arc::clone(&atomic_reader);

            scope.spawn(move |_| {
                loop {
                    // If work is available, do that work.
                    match utils::get_next_record(&reader) {
                        Some(result_record) => {
                            let record = match result_record {
                                Ok(record) => record,
                                Err(err) => panic!("Error {:?} in reading fastq", err),
                            };

                            let dna_string = str::from_utf8(record.seq()).unwrap();
                            let seq = DnaString::from_dna_string(dna_string);
                            let read_data = index.map_read(&seq);

                            let wrapped_read_data = match read_data {
                                Some((eq_class, coverage)) => {
                                    if coverage >= READ_COVERAGE_THRESHOLD && eq_class.is_empty() {
                                        Some((true, record.id().to_owned(), eq_class, coverage))
                                    } else {
                                        Some((false, record.id().to_owned(), eq_class, coverage))
                                    }
                                }
                                None => Some((false, record.id().to_owned(), Vec::new(), 0)),
                            };

                            tx.send(wrapped_read_data).expect("Could not send data!");
                        }
                        None => {
                            // send None to tell receiver that the queue ended
                            tx.send(None).expect("Could not send data!");
                            break;
                        }
                    }; //end-match
                } // end loop
            }); //end-scope
        } // end-for

        let mut read_counter: usize = 0;
        let mut mapped_read_counter: usize = 0;
        let mut dead_thread_count = 0;

        for eq_class in rx.iter() {
            match eq_class {
                None => {
                    dead_thread_count += 1;
                    if dead_thread_count == num_threads {
                        drop(tx);
                        break;
                    }
                }
                Some(read_data) => {
                    println!("{:?}", read_data);

                    if read_data.0 {
                        mapped_read_counter += 1;
                    }

                    read_counter += 1;
                    if read_counter % 1_000_000 == 0 {
                        let frac_mapped = mapped_read_counter as f32 * 100.0 / read_counter as f32;
                        eprint!(
                            "\rDone Mapping {} reads w/ Rate: {}",
                            read_counter, frac_mapped
                        );
                        io::stderr().flush().expect("Could not flush stdout");
                    }
                } // end-Some
            } // end-match
        } // end-for
    })
    .unwrap(); //end crossbeam

    eprintln!();
    info!("Done Mapping Reads");
    Ok(())
}