Skip to content

Commit

Permalink
Merge pull request #188 from saethlin/trim-deps
Browse files Browse the repository at this point in the history
Trim off a few more dependencies
  • Loading branch information
jonhoo authored Sep 27, 2020
2 parents 432d653 + 23e2d88 commit 86302c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ codecov = { repository = "jonhoo/inferno", branch = "master", service = "github"
[features]
default = ["cli", "multithreaded", "nameattr"]
cli = ["structopt", "env_logger"]
multithreaded = ["dashmap", "crossbeam", "num_cpus"]
multithreaded = ["dashmap", "crossbeam-utils", "crossbeam-channel", "num_cpus"]
nameattr = ["indexmap"]

[dependencies]
ahash = "0.3"
crossbeam = { version = "0.7", optional = true }
crossbeam-utils = { version = "0.7", optional = true }
crossbeam-channel = { version = "0.4", optional = true }
dashmap = { version = "3", optional = true }
env_logger = { version = "0.7", optional = true }
env_logger = { version = "0.7", default-features = false, optional = true }
indexmap = { version = "1.0", optional = true }
itoa = "0.4.3"
lazy_static = "1.3.0"
Expand Down
12 changes: 5 additions & 7 deletions src/collapse/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ use std::sync::Arc;

use ahash::AHashMap;
#[cfg(feature = "multithreaded")]
use crossbeam::channel;
#[cfg(feature = "multithreaded")]
use dashmap::DashMap;
use lazy_static::lazy_static;

Expand Down Expand Up @@ -199,19 +197,19 @@ pub trait CollapsePrivate: Send + Sized {
assert!(nthreads > 1);
assert!(occurrences.is_concurrent());

crossbeam::thread::scope(|scope| {
crossbeam_utils::thread::scope(|scope| {
// Channel for sending an error from the worker threads to the main thread
// in the event a worker has failed.
let (tx_error, rx_error) = channel::bounded::<io::Error>(1);
let (tx_error, rx_error) = crossbeam_channel::bounded::<io::Error>(1);

// Channel for sending input data from the main thread to the worker threads.
// We choose `2 * nthreads` as the channel size here in order to limit memory
// usage in the case of particularly large input files.
let (tx_input, rx_input) = channel::bounded::<Vec<u8>>(2 * nthreads);
let (tx_input, rx_input) = crossbeam_channel::bounded::<Vec<u8>>(2 * nthreads);

// Channel for worker threads that have errored to signal to all the other
// worker threads that they should stop work immediately and return.
let (tx_stop, rx_stop) = channel::bounded::<()>(nthreads - 1);
let (tx_stop, rx_stop) = crossbeam_channel::bounded::<()>(nthreads - 1);

let mut handles = Vec::with_capacity(nthreads);
for _ in 0..nthreads {
Expand All @@ -226,7 +224,7 @@ pub trait CollapsePrivate: Send + Sized {
// TODO: https://github.com/crossbeam-rs/crossbeam/issues/404
#[allow(clippy::drop_copy, clippy::zero_ptr)]
let handle = scope.spawn(move |_| loop {
channel::select! {
crossbeam_channel::select! {
recv(rx_input) -> input => {
// Receive input from the main thread.
let data = match input {
Expand Down

0 comments on commit 86302c8

Please sign in to comment.