Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: remove excess dependencies #4

Merged
merged 4 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,13 @@ maintenance = { status = "actively-developed" }

[dependencies]
tokio = { version = "1", features = ["sync", "time"] }
futures = "0.3"
futures-core = { version = "0.3", default-features = false }

[dev-dependencies]
futures-util = { version = "0.3", default-features = false }
tokio = { version = "1", features = ["test-util", "rt", "rt-multi-thread", "macros"] }
tokio-test = "^0.4"
loom = { version = "^0.4.0" }
criterion = { version="^0.3.4", features = ["async_tokio", "html_reports"] }

[target.'cfg(loom)'.dependencies]
loom = { version = "^0.4.0", features = ["futures", "checkpoint"] }
loom = { version = "0.5", features = ["futures", "checkpoint"] }
criterion = { version = "0.3", features = ["async_tokio", "html_reports"] }

[[test]]
name = "tests"
Expand All @@ -45,7 +42,6 @@ name = "tests"
name = "bench_channel_async"
harness = false


[[bench]]
name = "bench_channel_sync"
harness = false
2 changes: 1 addition & 1 deletion src/bounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::error::{ReceiveError, RequestError, RespondError, SendError};
use tokio::sync::{mpsc, oneshot};
use tokio::time::{timeout, Duration};

use futures::Stream;
use futures_core::Stream;
use std::pin::Pin;
use std::task::{Context, Poll};

Expand Down
21 changes: 9 additions & 12 deletions src/error.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::error::Error;
use std::fmt;
use tokio::sync::mpsc::error::{RecvError as MpscRecvError, SendError as MpscSendError};
use tokio::sync::mpsc::error::SendError as MpscSendError;
use tokio::sync::oneshot;

/// Error thrown when a [`RequestSender::send()`](crate::RequestSender::send()) or [`UnboundedRequestSender::send()`](crate::unbounded::UnboundedRequestSender::send())
Expand Down Expand Up @@ -51,13 +51,6 @@ pub enum ReceiveError {
TimeoutError,
}

// Cannot test this due to private field in the tokio error implementation
#[cfg(not(tarpaulin_include))]
impl<T> From<MpscRecvError> for RequestError<T> {
fn from(_err: MpscRecvError) -> RequestError<T> {
RequestError::RecvError
}
}
Comment on lines -54 to -60
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this was unused 👍

impl<T> From<SendError<T>> for RequestError<T> {
fn from(err: SendError<T>) -> RequestError<T> {
RequestError::SendError(err.0)
Expand Down Expand Up @@ -104,10 +97,14 @@ impl<T> Error for RequestError<T> where T: fmt::Debug {}

impl fmt::Display for ReceiveError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(fmt, "{}", match self {
ReceiveError::RecvError => "receive channel closed",
ReceiveError::TimeoutError => "request timed out"
})
write!(
fmt,
"{}",
match self {
ReceiveError::RecvError => "receive channel closed",
ReceiveError::TimeoutError => "request timed out",
}
)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/unbounded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::bounded::ResponseReceiver;
use tokio::sync::{mpsc, oneshot};
use tokio::time::Duration;

use futures::Stream;
use futures_core::Stream;
use std::pin::Pin;
use std::task::{Context, Poll};

Expand Down
15 changes: 6 additions & 9 deletions tests/loom_bounded.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
use loom::future::block_on;
use loom::thread;
use tokio_test::assert_err;
use tokio_test::assert_ok;

#[test]
#[cfg(not(tarpaulin))]
Expand All @@ -11,15 +9,15 @@ fn closing_tx() {

thread::spawn(move || {
let res = block_on(tx.send(4));
assert_ok!(res);
assert!(res.is_ok());
drop(tx);
});

let v = block_on(rx.recv());
assert_ok!(v);
assert!(v.is_ok());

let v = block_on(rx.recv());
assert_err!(v);
assert!(v.is_err());
})
}

Expand All @@ -32,17 +30,16 @@ fn closing_tx_res() {
thread::spawn(move || {
let res = block_on(tx.send(5));
let repl = block_on(res.unwrap().recv());
assert_ok!(repl);
assert_eq!(repl.unwrap(), 10);
assert_eq!(repl, Ok(10));
drop(tx);
});

let v = block_on(rx.recv());
let (req, responder) = v.unwrap();
let v = responder.respond(req * 2);
assert_ok!(v);
assert!(v.is_ok());

let v = block_on(rx.recv());
assert_err!(v);
assert!(v.is_err());
})
}
Loading