Skip to content

Commit

Permalink
Merge branch 'tim/tokio_12' into 'master'
Browse files Browse the repository at this point in the history
Drop async-channel and switch back to tokio

See merge request TankerHQ/sdk-rust!63
  • Loading branch information
tux3 committed Sep 22, 2021
2 parents 8136eba + a40e51a commit f427fe9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
6 changes: 2 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ include = ["native", "src", "tests", "build.rs"]
futures = "0.3"
num_enum = "0.5"
lazy_static = "1.4"
tokio = { version = "1.3", features = ["sync"] }
# Tokio's mpsc::sync channel has a bug in try_recv(), in the meantime we use async_channel
async-channel = "1.6.1"
tokio = { version = "1.12", features = ["sync"] }
libloading = "0.7.0"

[dev-dependencies]
tokio = { version = "1.3", features = ["macros", "rt-multi-thread"] }
tokio = { version = "1.12", features = ["macros", "rt-multi-thread"] }
reqwest = { version = "0.11", features = ["json", "rustls-tls"], default-features = false }
serde_json = "1.0"
double-checked-cell-async = "2.0.2"
Expand Down
6 changes: 3 additions & 3 deletions src/ctanker/cstream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use crate::ctanker::*;
use crate::error::Error;

use ::core::pin::Pin;
use async_channel::{bounded, Receiver, Sender, TryRecvError};
use futures::executor::block_on;
use futures::future::{select, Either};
use futures::io::{AsyncRead, AsyncReadExt};
Expand All @@ -35,6 +34,7 @@ use futures::FutureExt;
use std::cmp::min;
use std::future::Future;
use std::sync::Mutex;
use tokio::sync::mpsc::{channel, error::TryRecvError, Receiver, Sender};

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

impl<UserStream: AsyncRead + Unpin> TankerStream<UserStream> {
fn new() -> Self {
let (sender, receiver) = bounded(1);
let (sender, receiver) = channel(1);
TankerStream {
user_stream: None,
tanker_stream_handle: std::ptr::null_mut(),
Expand Down Expand Up @@ -190,7 +190,7 @@ impl<UserStream: AsyncRead + Unpin> AsyncRead for TankerStream<UserStream> {
);
self.read_operation = Some(read_operation);
}
Err(TryRecvError::Closed) => {
Err(TryRecvError::Disconnected) => {
panic!("error reading channel: closed");
}
Err(TryRecvError::Empty) => {} // Channel still open, but no message
Expand Down

0 comments on commit f427fe9

Please sign in to comment.