mirror of
https://github.com/sharkdp/fd.git
synced 2024-09-28 13:01:30 +02:00
Merge pull request #916 from tavianator/revert-crossbeam
Revert "Switch from std::sync::mpsc to crossbeam-channel"
This commit is contained in:
commit
ccc6cc54b2
11
Cargo.lock
generated
11
Cargo.lock
generated
@ -99,16 +99,6 @@ dependencies = [
|
|||||||
"vec_map",
|
"vec_map",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "crossbeam-channel"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"
|
|
||||||
dependencies = [
|
|
||||||
"cfg-if",
|
|
||||||
"crossbeam-utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crossbeam-utils"
|
name = "crossbeam-utils"
|
||||||
version = "0.8.5"
|
version = "0.8.5"
|
||||||
@ -165,7 +155,6 @@ dependencies = [
|
|||||||
"atty",
|
"atty",
|
||||||
"chrono",
|
"chrono",
|
||||||
"clap",
|
"clap",
|
||||||
"crossbeam-channel",
|
|
||||||
"ctrlc",
|
"ctrlc",
|
||||||
"diff",
|
"diff",
|
||||||
"dirs-next",
|
"dirs-next",
|
||||||
|
@ -49,7 +49,6 @@ dirs-next = "2.0"
|
|||||||
normpath = "0.3"
|
normpath = "0.3"
|
||||||
chrono = "0.4"
|
chrono = "0.4"
|
||||||
once_cell = "1.9.0"
|
once_cell = "1.9.0"
|
||||||
crossbeam-channel = "0.5.1"
|
|
||||||
|
|
||||||
[dependencies.clap]
|
[dependencies.clap]
|
||||||
version = "2.34.0"
|
version = "2.34.0"
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::sync::mpsc::Receiver;
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use crossbeam_channel::Receiver;
|
|
||||||
|
|
||||||
use crate::error::print_error;
|
use crate::error::print_error;
|
||||||
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
use crate::exit_codes::{merge_exitcodes, ExitCode};
|
||||||
use crate::walk::WorkerResult;
|
use crate::walk::WorkerResult;
|
||||||
|
10
src/walk.rs
10
src/walk.rs
@ -4,13 +4,13 @@ use std::io;
|
|||||||
use std::mem;
|
use std::mem;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::sync::atomic::{AtomicBool, Ordering};
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::thread;
|
use std::thread;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use std::{borrow::Cow, io::Write};
|
use std::{borrow::Cow, io::Write};
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender};
|
|
||||||
use ignore::overrides::OverrideBuilder;
|
use ignore::overrides::OverrideBuilder;
|
||||||
use ignore::{self, WalkBuilder};
|
use ignore::{self, WalkBuilder};
|
||||||
use once_cell::unsync::OnceCell;
|
use once_cell::unsync::OnceCell;
|
||||||
@ -55,7 +55,7 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<Config>) -> R
|
|||||||
let first_path_buf = path_iter
|
let first_path_buf = path_iter
|
||||||
.next()
|
.next()
|
||||||
.expect("Error: Path vector can not be empty");
|
.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());
|
let mut override_builder = OverrideBuilder::new(first_path_buf.as_path());
|
||||||
|
|
||||||
@ -232,7 +232,11 @@ impl<W: Write> ReceiverBuffer<W> {
|
|||||||
match self.mode {
|
match self.mode {
|
||||||
ReceiverMode::Buffering => {
|
ReceiverMode::Buffering => {
|
||||||
// Wait at most until we should switch to streaming
|
// 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 => {
|
ReceiverMode::Streaming => {
|
||||||
// Wait however long it takes for a result
|
// Wait however long it takes for a result
|
||||||
|
Loading…
Reference in New Issue
Block a user