Skip to content

Commit

Permalink
Merge pull request #47 from messense/reduce-futures
Browse files Browse the repository at this point in the history
Replace futures with futures-util
  • Loading branch information
tatsuya6502 authored Sep 22, 2021
2 parents 5a35152 + e0b9f42 commit 5301904
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ features = ["future"]
default = ["atomic64"]

# Enable this feature to use `moka::future::Cache`.
future = ["async-io", "async-lock", "futures"]
future = ["async-io", "async-lock", "futures-util"]

# This feature is enabled by default. Disable it when the target platform does not
# support `std::sync::atomic::AtomicU64`. (e.g. `armv5te-unknown-linux-musleabi`
Expand All @@ -45,7 +45,7 @@ uuid = { version = "0.8", features = ["v4"] }
# Optional dependencies
async-io = { version = "1.4", optional = true }
async-lock = { version = "2.4", optional = true }
futures = { version = "0.3", optional = true }
futures-util = { version = "0.3", optional = true }

[dev-dependencies]
actix-rt2 = { package = "actix-rt", version = "2", default-features = false }
Expand Down
12 changes: 6 additions & 6 deletions src/future/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ use std::{
/// .collect();
///
/// // Wait for all tasks to complete.
/// futures::future::join_all(tasks).await;
/// futures_util::future::join_all(tasks).await;
///
/// // Verify the result.
/// for key in 0..(NUM_TASKS * NUM_KEYS_PER_TASK) {
Expand Down Expand Up @@ -323,7 +323,7 @@ where
/// .collect();
///
/// // Run all tasks concurrently and wait for them to complete.
/// futures::future::join_all(tasks).await;
/// futures_util::future::join_all(tasks).await;
/// }
/// ```
///
Expand Down Expand Up @@ -422,7 +422,7 @@ where
/// .collect();
///
/// // Run all tasks concurrently and wait for them to complete.
/// futures::future::join_all(tasks).await;
/// futures_util::future::join_all(tasks).await;
/// }
/// ```
///
Expand Down Expand Up @@ -888,7 +888,7 @@ mod tests {
})
.collect::<Vec<_>>();

let _ = futures::future::join_all(tasks).await;
let _ = futures_util::future::join_all(tasks).await;

assert!(cache.get(&10).is_none());
assert!(cache.get(&20).is_some());
Expand Down Expand Up @@ -1173,7 +1173,7 @@ mod tests {
}
};

futures::join!(task1, task2, task3, task4, task5);
futures_util::join!(task1, task2, task3, task4, task5);
}

#[tokio::test]
Expand Down Expand Up @@ -1315,7 +1315,7 @@ mod tests {
}
};

futures::join!(task1, task2, task3, task4, task5, task6, task7, task8);
futures_util::join!(task1, task2, task3, task4, task5, task6, task7, task8);
}

#[tokio::test]
Expand Down
2 changes: 1 addition & 1 deletion src/future/value_initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ where
C: FnMut(&'a Arc<K>, O, &mut WaiterValue<V>) -> InitResult<V, E>,
E: Send + Sync + 'static,
{
use futures::future::FutureExt;
use futures_util::FutureExt;
use std::panic::{resume_unwind, AssertUnwindSafe};
use InitResult::*;

Expand Down
2 changes: 1 addition & 1 deletion tests/runtime_actix_rt1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn main() {
.collect();

// Wait for all tasks to complete.
futures::future::join_all(tasks).await;
futures_util::future::join_all(tasks).await;

// Verify the result.
for key in 0..(NUM_TASKS * NUM_KEYS_PER_TASK) {
Expand Down
2 changes: 1 addition & 1 deletion tests/runtime_actix_rt2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn main() {
.collect();

// Wait for all tasks to complete.
futures::future::join_all(tasks).await;
futures_util::future::join_all(tasks).await;

// Verify the result.
for key in 0..(NUM_TASKS * NUM_KEYS_PER_TASK) {
Expand Down
2 changes: 1 addition & 1 deletion tests/runtime_async_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async fn main() {
.collect();

// Wait for all tasks to complete.
futures::future::join_all(tasks).await;
futures_util::future::join_all(tasks).await;

// Verify the result.
for key in 0..(NUM_TASKS * NUM_KEYS_PER_TASK) {
Expand Down
2 changes: 1 addition & 1 deletion tests/runtime_tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async fn main() {
.collect();

// Wait for all tasks to complete.
futures::future::join_all(tasks).await;
futures_util::future::join_all(tasks).await;

// Verify the result.
for key in 0..(NUM_TASKS * NUM_KEYS_PER_TASK) {
Expand Down

0 comments on commit 5301904

Please sign in to comment.