Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Configuration setting
  • Loading branch information
benashford committed Dec 26, 2020
commit cd5da8eea8cdc320c552ea617019ce618d579f5f
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tokio-util_06 = { package = "tokio-util", version = "0.6", features = ["codec"],
[dev-dependencies]
env_logger = "^0.8.1"
futures = "^0.3.7"
async-std = "1.8"
async-std = { version = "1.8", features = ["attributes"] }
tokio_02 = { package = "tokio", version = "0.2", features = ["full"] }
tokio_10 = { package = "tokio", version = "1.0", features = ["full"] }

Expand Down
11 changes: 11 additions & 0 deletions examples/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@ use futures::{sink::SinkExt, stream::StreamExt};

use redis_async::{client, resp_array};

#[cfg(feature = "with_tokio")]
#[tokio::main]
async fn main() {
do_main().await;
}

#[cfg(feature = "with_async_std")]
#[async_std::main]
async fn main() {
do_main().await;
}

async fn do_main() {
let addr = env::args()
.nth(1)
.unwrap_or_else(|| "127.0.0.1:6379".to_string())
Expand Down
2 changes: 1 addition & 1 deletion src/client/connect/async_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use futures_util::stream::Stream;

use crate::{error::Error, protocol::resp::RespValue};

pub(crate) struct RespTcpStream {
pub struct RespTcpStream {
tcp_stream: TcpStream,
}

Expand Down
6 changes: 5 additions & 1 deletion src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ where
}

#[cfg(feature = "with_async_std")]
pub(crate) fn spawn<F>(f: F) {
pub(crate) fn spawn<F>(f: F)
where
F: Future + Send + 'static,
F::Output: Send,
{
async_global_executor::spawn(f).detach()
}