Skip to content

Instantly share code, notes, and snippets.

@brigand

brigand/.diff Secret

Created March 11, 2018 04:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brigand/efd5328db5a4209e5212cd76b12693cc to your computer and use it in GitHub Desktop.
Save brigand/efd5328db5a4209e5212cd76b12693cc to your computer and use it in GitHub Desktop.
diff --git a/src/client/paired.rs b/src/client/paired.rs
index 25e5216..3b88af0 100644
--- a/src/client/paired.rs
+++ b/src/client/paired.rs
@@ -13,8 +13,8 @@ use std::net::SocketAddr;
use std::sync::{Arc, Mutex};
use futures::{future, Future, Sink, Stream};
-use futures::future::Executor;
use futures::sync::{mpsc, oneshot};
+use tokio::executor::{Executor, DefaultExecutor};
use error;
use resp;
@@ -25,13 +25,12 @@ type PairedConnectionBox = Box<Future<Item = PairedConnection, Error = error::Er
/// The default starting point to use most default Redis functionality.
///
/// Returns a future that resolves to a `PairedConnection`.
-pub fn paired_connect<E>(addr: &SocketAddr, executor: E) -> PairedConnectionBox
-where
- E: Executor<Box<Future<Item = (), Error = ()> + Send>> + 'static,
+pub fn paired_connect(addr: &SocketAddr) -> PairedConnectionBox
{
let paired_con = connect(addr)
.map_err(|e| e.into())
.and_then(move |connection| {
+ let mut executor = DefaultExecutor::current();
let ClientConnection { sender, receiver } = connection;
let (out_tx, out_rx) = mpsc::unbounded();
let running = Arc::new(Mutex::new(true));
@@ -86,8 +85,9 @@ where
) as Box<Future<Item = (), Error = ()> + Send>;
match executor
- .execute(sender)
- .and_then(|_| executor.execute(receiver))
+ .spawn(sender)
+ .and_then(|_| executor.spawn(receiver))
+
{
Ok(()) => future::ok(PairedConnection {
out_tx: out_tx,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment