Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace futures with futures-util #47

Merged
merged 1 commit into from
Sep 22, 2021
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
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