Merge pull request #916 from tavianator/revert-crossbeam
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Revert "Switch from std::sync::mpsc to crossbeam-channel"
authored by David Peter · committed by GitHub · parents aa1c025, aa6933d · Browse files · 4 files·+8 added−17 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+8 added−17 removed
- other:+8 added−17 removed
Provenance
- Commit
ccc6cc5- Tree
1b895f7- Author
David Peter <sharkdp@users.noreply.github.com>- Committer
GitHub <noreply@github.com>- Parent 1
aa1c025- Parent 2
aa6933d
4 files changed+8 added−17 removed
modified:src/exec/job.rs+1 added-2 removed
1 use std::path::PathBuf;2+use std::sync::mpsc::Receiver;3 use std::sync::{Arc, Mutex};4 4-use crossbeam_channel::Receiver;5-5 use crate::error::print_error;6 use crate::exit_codes::{merge_exitcodes, ExitCode};7 use crate::walk::WorkerResult;8 69 unmodified linesmodified:src/walk.rs+7 added-3 removed
2 unmodified lines3 use std::io;4 use std::mem;5 use std::path::{Path, PathBuf};6 use std::sync::atomic::{AtomicBool, Ordering};7+use std::sync::mpsc::{channel, Receiver, RecvTimeoutError, Sender};8 use std::sync::{Arc, Mutex};9 use std::thread;10 use std::time::{Duration, Instant};11 use std::{borrow::Cow, io::Write};12 13 use anyhow::{anyhow, Result};13-use crossbeam_channel::{unbounded, Receiver, RecvTimeoutError, Sender};14 use ignore::overrides::OverrideBuilder;15 use ignore::{self, WalkBuilder};16 use once_cell::unsync::OnceCell;17 use regex::bytes::Regex;36 unmodified lines54 let mut path_iter = path_vec.iter();55 let first_path_buf = path_iter56 .next()57 .expect("Error: Path vector can not be empty");58- let (tx, rx) = unbounded();58+ let (tx, rx) = channel();59 60 let mut override_builder = OverrideBuilder::new(first_path_buf.as_path());61 62 for pattern in &config.exclude_patterns {168 unmodified lines231 fn recv(&self) -> Result<WorkerResult, RecvTimeoutError> {232 match self.mode {233 ReceiverMode::Buffering => {234 // Wait at most until we should switch to streaming235- self.rx.recv_deadline(self.deadline)235+ let now = Instant::now();236+ self.deadline237+ .checked_duration_since(now)238+ .ok_or(RecvTimeoutError::Timeout)239+ .and_then(|t| self.rx.recv_timeout(t))240 }241 ReceiverMode::Streaming => {242 // Wait however long it takes for a result243 Ok(self.rx.recv()?)388 unmodified linesmodified:Cargo.lock-11 removed
98 unmodified lines99 "vec_map",100 ]101 102 [[package]]103-name = "crossbeam-channel"104-version = "0.5.1"105-source = "registry+https://github.com/rust-lang/crates.io-index"106-checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4"107-dependencies = [108- "cfg-if",109- "crossbeam-utils",110-]111-112-[[package]]103 name = "crossbeam-utils"104 version = "0.8.5"105 source = "registry+https://github.com/rust-lang/crates.io-index"106 checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db"47 unmodified lines154 "anyhow",155 "atty",156 "chrono",157 "clap",168- "crossbeam-channel",158 "ctrlc",159 "diff",160 "dirs-next",161 "filetime",497 unmodified linesmodified:Cargo.toml-1 removed
47 unmodified lines48495051525253545527 unmodified lines47 unmodified linesdirs-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"features = ["suggestions", "color", "wrap_help"]27 unmodified lines