Skip to content

Commit

Permalink
Use non-sync channel
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Nov 26, 2021
1 parent e990a13 commit f219da4
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fs::{FileType, Metadata};
use std::io;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{sync_channel, Receiver, SyncSender as Sender};
use std::sync::mpsc::{channel, Receiver, Sender};
use std::sync::{Arc, Mutex};
use std::thread;
use std::time;
Expand All @@ -22,12 +22,6 @@ use crate::exit_codes::{merge_exitcodes, ExitCode};
use crate::filesystem;
use crate::output;

pub const WORKER_CHANNEL_DEFAULT_BOUND: usize = 1000;

pub fn make_worker_channel() -> (Sender<WorkerResult>, Receiver<WorkerResult>) {
sync_channel(WORKER_CHANNEL_DEFAULT_BOUND)
}

/// The receiver thread can either be buffering results or directly streaming to the console.
enum ReceiverMode {
/// Receiver is still buffering in order to sort the results, if the search finishes fast
Expand Down Expand Up @@ -59,7 +53,7 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<Config>) -> R
let first_path_buf = path_iter
.next()
.expect("Error: Path vector can not be empty");
let (tx, rx) = make_worker_channel();
let (tx, rx) = channel();

let mut override_builder = OverrideBuilder::new(first_path_buf.as_path());

Expand Down

0 comments on commit f219da4

Please sign in to comment.