Skip to content

Commit

Permalink
Upgrade traits to futures 0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
sagebind committed Nov 7, 2019
1 parent 3c1a3c2 commit 32c1e5e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 19 deletions.
14 changes: 6 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "sluice"
version = "0.4.2"
version = "0.5.0"
authors = ["Stephen M. Coakley <[email protected]>"]
edition = "2018"
description = "Efficient ring buffer for byte buffers, FIFO queues, and SPSC channels"
Expand All @@ -11,17 +11,15 @@ keywords = ["buffer", "pipe", "channel"]
categories = ["asynchronous", "concurrency", "data-structures"]
license = "MIT"

[features]
nightly = []

[dependencies]
futures-channel-preview = "0.3.0-alpha.18"
futures-core-preview = "0.3.0-alpha.18"
futures-io-preview = "0.3.0-alpha.18"
futures-channel = "0.3"
futures-core = "0.3"
futures-io = "0.3"
futures-util = "0.3"

[dev-dependencies]
criterion = "0.3"
futures-preview = "0.3.0-alpha.18"
futures = "0.3"

[[bench]]
name = "pipe"
Expand Down
15 changes: 5 additions & 10 deletions benches/pipe.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,27 @@
#![cfg(feature = "nightly")]
#![feature(async_await)]

use criterion::*;

fn benchmark(c: &mut Criterion) {
c.bench_function("write 100 1K chunks", |b| {
use futures::executor::ThreadPool;
use futures::prelude::*;

let mut pool = ThreadPool::new().unwrap();
let data = [1; 1024];

b.iter_batched(
sluice::pipe::pipe,
|(mut reader, mut writer)| {
|(reader, mut writer)| {
let producer = async {
for _ in 0..100 {
for _ in 0u8..100 {
writer.write_all(&data).await.unwrap();
}
writer.close().await.unwrap();
};

let consumer = async {
let mut sink = std::io::sink();
reader.copy_into(&mut sink).await.unwrap();
let mut sink = futures::io::sink();
futures::io::copy(reader, &mut sink).await.unwrap();
};

pool.run(future::join(producer, consumer));
futures::executor::block_on(future::join(producer, consumer));
},
BatchSize::SmallInput,
)
Expand Down
2 changes: 1 addition & 1 deletion src/pipe/chunked.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
use futures_channel::mpsc;
use futures_core::{FusedStream, Stream};
use futures_io::{AsyncRead, AsyncWrite};
use futures_util::io::Cursor;
use std::{
io,
io::Cursor,
pin::Pin,
task::{Context, Poll},
};
Expand Down

0 comments on commit 32c1e5e

Please sign in to comment.