pub fn job(
    rx: Arc<Mutex<Receiver<WorkerResult>>>,
    cmd: Arc<CommandTemplate>,
    out_perm: Arc<Mutex<()>>,
    show_filesystem_errors: bool,
) {
    loop {
        // Create a lock on the shared receiver for this thread.
        let lock = rx.lock().unwrap();

        // Obtain the next result from the receiver, else if the channel
        // has closed, exit from the loop
        let value: PathBuf = match lock.recv() {
            Ok(WorkerResult::Entry(val)) => val,
            Ok(WorkerResult::Error(err)) => {
                if show_filesystem_errors {
                    print_error!("{}", err);
                }
                continue;
            }
            Err(_) => break,
        };

        // Drop the lock so that other threads can read from the the receiver.
        drop(lock);
        // Generate a command and execute it.
        cmd.generate_and_execute(&value, Arc::clone(&out_perm));
    }
}
/// An event loop that listens for inputs from the `rx` receiver. Each received input will
/// generate a command with the supplied command template. The generated command will then
/// be executed, and this process will continue until the receiver's sender has closed.
An event loop that listens for inputs from the `rx` receiver. Each received input will
generate a command with the supplied command template. The generated command will then
be executed, and this process will continue until the receiver's sender has closed.
An event loop that listens for inputs from the ` rx ` receiver . Each received input will generate a command with the supplied command template . The generated command will then be executed and this process will continue until the receiver ' s sender has closed .
pub fn job(
    rx: Arc<Mutex<Receiver<WorkerResult>>>,
    cmd: Arc<CommandTemplate>,
    out_perm: Arc<Mutex<()>>,
    show_filesystem_errors: bool,
) {
    loop {
        // Create a lock on the shared receiver for this thread.
        let lock = rx.lock().unwrap();
        // Obtain the next result from the receiver, else if the channel
        // has closed, exit from the loop
        let value: PathBuf = match lock.recv() {
            Ok(WorkerResult::Entry(val)) => val,
            Ok(WorkerResult::Error(err)) => {
                if show_filesystem_errors {
                    print_error!("{}", err);
                }
                continue;
            }
            Err(_) => break,
        };
        // Drop the lock so that other threads can read from the the receiver.
        drop(lock);
        // Generate a command and execute it.
        cmd.generate_and_execute(&value, Arc::clone(&out_perm));
    }
}
pub fn job ( rx : Arc < Mutex < Receiver < WorkerResult > > > , cmd : Arc < CommandTemplate > , out_perm : Arc < Mutex < ( ) > > , show_filesystem_errors : bool , ) { loop { // Create a lock on the shared receiver for this thread. let lock = rx . lock ( ) . unwrap ( ) ; // Obtain the next result from the receiver, else if the channel // has closed, exit from the loop let value : PathBuf = match lock . recv ( ) { Ok ( WorkerResult :: Entry ( val ) ) => val , Ok ( WorkerResult :: Error ( err ) ) => { if show_filesystem_errors { print_error ! ( " " err ) ; } continue ; } Err ( _ ) => break , } ; // Drop the lock so that other threads can read from the the receiver. drop ( lock ) ; // Generate a command and execute it. cmd . generate_and_execute ( & value , Arc :: clone ( & out_perm ) ) ; } }
An event loop that listens for inputs from the `rx` receiver.
An event loop that listens for inputs from the ` rx ` receiver .
rx
Arc<Mutex<Receiver<WorkerResult>>>
cmd
Arc<CommandTemplate>
out_perm
Arc<Mutex<()>>
show_filesystem_errors
bool