Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Update parking_lot and fix deprecation warnings on Box<Future>s #6

Merged
merged 2 commits into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
[package]
name = "aio-limited"
version = "0.1.0"
version = "0.1.1"
authors = ["Parity Technologies <admin@parity.io>"]
license = "Apache-2.0 OR MIT"
description = "Rate-limited async I/O."
repository = "https://github.com/paritytech/aio-limited"
readme = "README.md"
edition = "2018"

[dependencies]
futures = "0.1"
log = "0.4"
parking_lot = "0.5"
parking_lot = "0.9"
tokio-executor = "0.1"
tokio-io = "0.1"
tokio-timer = "0.2"

[dev-dependencies]
env_logger = "0.5"
env_logger = "0.6"
tokio = "0.1"

4 changes: 2 additions & 2 deletions src/algorithms/bucket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// at https://opensource.org/licenses/MIT.

use crate::{algorithms::{Id, Token}, error::{Error, Result}};
use parking_lot::Mutex;
use parking_lot::{Mutex, lock_api::MutexGuard};
use std::{cmp::min, sync::atomic::{AtomicUsize, Ordering}};

/// A bucket has a certain capacity which is made available as `Token`s
Expand Down Expand Up @@ -73,7 +73,7 @@ impl Bucket {

cap.value -= quant;
let t = Token::new(cap.index, quant);
cap.unlock_fair();
MutexGuard::unlock_fair(cap);
Ok(t)
}

Expand Down
10 changes: 0 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@
// at https://www.apache.org/licenses/LICENSE-2.0 and a copy of the MIT license
// at https://opensource.org/licenses/MIT.

extern crate futures;
extern crate log;
extern crate parking_lot;
extern crate tokio_executor;
extern crate tokio_io;
extern crate tokio_timer;

#[cfg(test)]
extern crate tokio;

mod algorithms;
mod error;
mod limited;
Expand Down
10 changes: 5 additions & 5 deletions src/limiter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ mod tests {
addr: &str,
lr: Option<Limiter>,
lw: Limiter,
) -> Box<Future<Item = (), Error = ()> + Send> {
) -> Box<dyn Future<Item = (), Error = ()> + Send> {
let srv = TcpListener::bind(&addr.parse().unwrap())
.unwrap()
.incoming()
Expand All @@ -123,9 +123,9 @@ mod tests {
let (r, w) = s.split();
let reader = match lr {
Some(ref lim) => {
Box::new(Limited::new(r, lim.clone()).unwrap()) as Box<AsyncRead + Send>
Box::new(Limited::new(r, lim.clone()).unwrap()) as Box<dyn AsyncRead + Send>
}
None => Box::new(r) as Box<AsyncRead + Send>,
None => Box::new(r) as Box<dyn AsyncRead + Send>,
};
let writer = Limited::new(w, lw.clone()).unwrap();
let future = copy(reader, writer)
Expand All @@ -136,7 +136,7 @@ mod tests {
Box::new(srv)
}

fn echo_client(addr: &str) -> Box<Future<Item = (), Error = ()> + Send> {
fn echo_client(addr: &str) -> Box<dyn Future<Item = (), Error = ()> + Send> {
let clt = TcpStream::connect(&addr.parse().unwrap())
.and_then(|stream| copy(&b"0123456789"[..], stream))
.and_then(|(n, _, stream)| read_exact(stream, vec![0; n as usize]))
Expand All @@ -145,7 +145,7 @@ mod tests {
Box::new(clt)
}

fn echo_rate_client(addr: &str, size: usize) -> Box<Future<Item = (), Error = ()> + Send> {
fn echo_rate_client(addr: &str, size: usize) -> Box<dyn Future<Item = (), Error = ()> + Send> {
let clt = TcpStream::connect(&addr.parse().unwrap())
.and_then(move |stream| {
Delay::new(Instant::now() + Duration::from_secs(1)).then(|_| Ok(stream))
Expand Down