Skip to content

Commit

Permalink
switch to std::sync::mpsc from crossbeam-channel
Browse files Browse the repository at this point in the history
Since Rust 1.72, Sender<T> implements Send if T: Send, which lets us use
it instead of crossbeam-channel - one less dependency.

Bumps MSRV to 1.72.
  • Loading branch information
MaxVerevkin committed Aug 24, 2023
1 parent b55befe commit b53eb21
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 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 @@ -32,7 +32,6 @@ calibright = { version = "0.1", features = ["watch"] }
chrono = { version = "0.4", default-features = false, features = ["clock", "unstable-locales"] }
chrono-tz = { version = "0.8", features = ["serde"] }
clap = { version = "4.0", default-features = false, features = ["std", "derive", "help", "usage"] }
crossbeam-channel = "0.5"
dirs = "5.0"
env_logger = "0.10"
futures = { version = "0.3", default-features = false }
Expand Down
12 changes: 5 additions & 7 deletions src/blocks/sound/pulseaudio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ use libpulse_binding::mainloop::standard::{IterateResult, Mainloop};
use libpulse_binding::proplist::{properties, Proplist};
use libpulse_binding::volume::{ChannelVolumes, Volume};

use crossbeam_channel::{unbounded, Sender};

use std::cmp::{max, min};
use std::convert::{TryFrom, TryInto};
use std::io;
Expand Down Expand Up @@ -49,7 +47,7 @@ struct Connection {
}

struct Client {
send_req: Sender<ClientRequest>,
send_req: std::sync::mpsc::Sender<ClientRequest>,
ml_waker: MainloopWaker,
}

Expand Down Expand Up @@ -198,7 +196,7 @@ impl Connection {

impl Client {
fn new() -> Result<Client> {
let (send_req, recv_req) = unbounded();
let (send_req, recv_req) = std::sync::mpsc::channel();
let ml_waker = MainloopWaker::new().unwrap();

Connection::spawn("sound_pulseaudio", move |mut connection| {
Expand Down Expand Up @@ -238,11 +236,11 @@ impl Client {
}

loop {
use std::sync::mpsc::TryRecvError;
let req = match recv_req.try_recv() {
Ok(x) => x,
Err(e) if e.is_empty() => break,
Err(e) if e.is_disconnected() => return false,
Err(_) => unreachable!(),
Err(TryRecvError::Empty) => break,
Err(TryRecvError::Disconnected) => return false,
};

use ClientRequest::*;
Expand Down

0 comments on commit b53eb21

Please sign in to comment.