Skip to content

Commit f0f13bc

Browse files
committed
Use crossbeam_channel instead of std::sync::mpsc.
Slightly speedup things (even if not a lot compared to full use case)
1 parent 0685afe commit f0f13bc

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ categories = ["concurrency", "data-structures"]
1111

1212

1313
[dependencies]
14+
crossbeam-channel = "0.5.12"
1415

src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,17 @@ impl<T: Send + 'static> Clone for Dropper<T> {
9494
}
9595

9696
mod inner {
97-
use std::{sync::mpsc, thread};
97+
use crossbeam_channel::{unbounded, Sender};
98+
use std::thread;
9899

99100
pub struct Dropper<T: Send> {
100-
drop_sender: Option<mpsc::Sender<T>>,
101+
drop_sender: Option<Sender<T>>,
101102
thread_handle: Option<thread::JoinHandle<()>>,
102103
}
103104

104105
impl<T: Send + 'static> Dropper<T> {
105106
pub fn new() -> Self {
106-
let (drop_sender, drop_receiver) = mpsc::channel();
107+
let (drop_sender, drop_receiver) = unbounded();
107108
let thread_handle = thread::Builder::new()
108109
.name("Dropout".into())
109110
.spawn(move || while let Ok(_) = drop_receiver.recv() {})

0 commit comments

Comments
 (0)