Skip to content

Commit

Permalink
Merge pull request sharkdp#916 from tavianator/revert-crossbeam
Browse files Browse the repository at this point in the history
Revert "Switch from std::sync::mpsc to crossbeam-channel"
  • Loading branch information
sharkdp authored Jan 6, 2022
2 parents aa1c025 + aa6933d commit ccc6cc5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 17 deletions.
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ dirs-next = "2.0"
normpath = "0.3"
chrono = "0.4"
once_cell = "1.9.0"
crossbeam-channel = "0.5.1"

[dependencies.clap]
version = "2.34.0"
Expand Down
3 changes: 1 addition & 2 deletions src/exec/job.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::path::PathBuf;
use std::sync::mpsc::Receiver;
use std::sync::{Arc, Mutex};

use crossbeam_channel::Receiver;

use crate::error::print_error;
use crate::exit_codes::{merge_exitcodes, ExitCode};
use crate::walk::WorkerResult;
Expand Down
10 changes: 7 additions & 3 deletions src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ use std::io;
use std::mem;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
use std::sync::{Arc, Mutex};
use std::thread;
use std::time::{Duration, Instant};
use std::{borrow::Cow, io::Write};

use anyhow::{anyhow, Result};
use crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender};
use ignore::overrides::OverrideBuilder;
use ignore::{self, WalkBuilder};
use once_cell::unsync::OnceCell;
Expand Down Expand Up @@ -55,7 +55,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) = unbounded();
let (tx, rx) = channel();

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

Expand Down Expand Up @@ -232,7 +232,11 @@ impl<W: Write> ReceiverBuffer<W> {
match self.mode {
ReceiverMode::Buffering => {
// Wait at most until we should switch to streaming
self.rx.recv_deadline(self.deadline)
let now = Instant::now();
self.deadline
.checked_duration_since(now)
.ok_or(RecvTimeoutError::Timeout)
.and_then(|t| self.rx.recv_timeout(t))
}
ReceiverMode::Streaming => {
// Wait however long it takes for a result
Expand Down

0 comments on commit ccc6cc5

Please sign in to comment.