Skip to content

Commit f427fe9

Browse files
committed
Merge branch 'tim/tokio_12' into 'master'
Drop async-channel and switch back to tokio See merge request TankerHQ/sdk-rust!63
2 parents 8136eba + a40e51a commit f427fe9

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

Diff for: Cargo.toml

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ include = ["native", "src", "tests", "build.rs"]
1111
futures = "0.3"
1212
num_enum = "0.5"
1313
lazy_static = "1.4"
14-
tokio = { version = "1.3", features = ["sync"] }
15-
# Tokio's mpsc::sync channel has a bug in try_recv(), in the meantime we use async_channel
16-
async-channel = "1.6.1"
14+
tokio = { version = "1.12", features = ["sync"] }
1715
libloading = "0.7.0"
1816

1917
[dev-dependencies]
20-
tokio = { version = "1.3", features = ["macros", "rt-multi-thread"] }
18+
tokio = { version = "1.12", features = ["macros", "rt-multi-thread"] }
2119
reqwest = { version = "0.11", features = ["json", "rustls-tls"], default-features = false }
2220
serde_json = "1.0"
2321
double-checked-cell-async = "2.0.2"

Diff for: src/ctanker/cstream.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use crate::ctanker::*;
2525
use crate::error::Error;
2626

2727
use ::core::pin::Pin;
28-
use async_channel::{bounded, Receiver, Sender, TryRecvError};
2928
use futures::executor::block_on;
3029
use futures::future::{select, Either};
3130
use futures::io::{AsyncRead, AsyncReadExt};
@@ -35,6 +34,7 @@ use futures::FutureExt;
3534
use std::cmp::min;
3635
use std::future::Future;
3736
use std::sync::Mutex;
37+
use tokio::sync::mpsc::{channel, error::TryRecvError, Receiver, Sender};
3838

3939
#[derive(Debug, Clone)]
4040
struct ReadOperation {
@@ -63,7 +63,7 @@ struct TankerStream<UserStream: AsyncRead + Unpin> {
6363

6464
impl<UserStream: AsyncRead + Unpin> TankerStream<UserStream> {
6565
fn new() -> Self {
66-
let (sender, receiver) = bounded(1);
66+
let (sender, receiver) = channel(1);
6767
TankerStream {
6868
user_stream: None,
6969
tanker_stream_handle: std::ptr::null_mut(),
@@ -190,7 +190,7 @@ impl<UserStream: AsyncRead + Unpin> AsyncRead for TankerStream<UserStream> {
190190
);
191191
self.read_operation = Some(read_operation);
192192
}
193-
Err(TryRecvError::Closed) => {
193+
Err(TryRecvError::Disconnected) => {
194194
panic!("error reading channel: closed");
195195
}
196196
Err(TryRecvError::Empty) => {} // Channel still open, but no message

0 commit comments

Comments
 (0)