Depend on futures-util instead of futures

This commit is contained in:
TechnoPorg committed 2026-02-11 22:44:01 +01:00
1 parent f342e33f16
commit a75defa5a6
79 files changed
+447 -380

No files matched your search

+10 -10
View File
@@ -2,7 +2,7 @@
use crate::common::task_fn;
use dagx::{task, DagRunner};
use futures::FutureExt;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
use std::time::Duration;
@@ -31,7 +31,7 @@ async fn test_concurrent_run_calls() {
for _ in 0..5 {
let dag = Arc::clone(&dag);
handles.spawn(async move { dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await });
handles.spawn(async move { dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() }).await });
}
// Only one run should succeed, others should fail with concurrent execution error
@@ -66,7 +66,7 @@ async fn test_concurrent_execution_and_building() {
.collect();
// Execute the initial DAG
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await
.unwrap();
@@ -95,7 +95,7 @@ async fn test_concurrent_execution_and_building() {
}
// Execute again with the new tasks
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await
.unwrap();
}
@@ -139,7 +139,7 @@ async fn test_dag_builder_thread_safety() {
assert_eq!(counter.load(Ordering::SeqCst), 10);
// Execute the combined DAG
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await
.unwrap();
@@ -161,7 +161,7 @@ async fn test_concurrent_get_operations() {
.map(|i| dag.add_task(task_fn::<(), _, _>(move |_: ()| i)))
.collect();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await
.unwrap();
@@ -213,7 +213,7 @@ async fn test_no_race_in_dependency_tracking() {
}
// Execute
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await
.unwrap();
@@ -273,7 +273,7 @@ async fn test_high_concurrency_stress() {
assert_eq!(completed.load(Ordering::SeqCst), 1000);
// The DAG should still be executable
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await
.unwrap();
}
@@ -363,7 +363,7 @@ async fn test_atomic_dag_operations() {
assert_eq!(deps.len(), 50);
// Execute and verify
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await
.unwrap();
@@ -416,7 +416,7 @@ async fn test_no_deadlock_on_circular_waiting() {
assert!(result.is_ok(), "Deadlock detected - operation timed out");
// Should be able to execute the DAG
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap))
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await
.unwrap();
}
+4 -4
View File
@@ -2,7 +2,7 @@
use crate::common::task_fn;
use dagx::{task, DagResult, DagRunner, TaskHandle};
use futures::FutureExt;
use std::sync::{Arc, Mutex};
use std::time::{Duration, Instant};
use tokio::time::sleep;
@@ -87,7 +87,7 @@ async fn test_layers_execute_in_parallel() -> DagResult<()> {
.depends_on((&layer1[0], &layer1[1], &layer1[2]))
};
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() }).await?;
assert_eq!(dag.get(final_task)?, 33); // (0+1) + (10+1) + (20+1)
@@ -213,7 +213,7 @@ async fn test_completion_order_matches_dependencies() -> DagResult<()> {
.depends_on(c)
};
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() }).await?;
assert_eq!(dag.get(d)?, 6); // (1 + 2) * 2
@@ -313,7 +313,7 @@ async fn test_dependent_tasks_respect_ordering() -> DagResult<()> {
.depends_on(c)
};
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() }).await?;
// Verify results
assert_eq!(dag.get(a)?, 1);
+3 -2
View File
@@ -2,7 +2,7 @@
use crate::common::task_fn;
use dagx::{DagResult, DagRunner};
use futures::FutureExt;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::Arc;
@@ -27,7 +27,8 @@ async fn test_spawner_actually_spawns_tasks() -> DagResult<()> {
.collect();
// Custom spawner that counts invocations
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await?;
// Verify all tasks were spawned
for (i, task) in tasks.into_iter().enumerate() {
+9 -5
View File
@@ -2,7 +2,7 @@
use crate::common::task_fn;
use dagx::{task, DagResult, DagRunner, TaskHandle};
use futures::FutureExt;
use std::collections::HashSet;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex};
@@ -52,7 +52,8 @@ async fn test_tasks_run_on_different_threads() -> DagResult<()> {
})
.collect();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await?;
// Verify all tasks completed
for task in tasks.into_iter() {
@@ -129,7 +130,8 @@ async fn test_concurrent_execution_with_atomic_counter() -> DagResult<()> {
})
.collect();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await?;
// Verify all tasks completed
for (i, task) in tasks.into_iter().enumerate() {
@@ -212,7 +214,8 @@ async fn test_diamond_parallel_execution() -> DagResult<()> {
.add_task(task_fn::<(i32, i32), _, _>(|(a, b): (&i32, &i32)| a + b))
.depends_on((&parallel1, &parallel2));
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await?;
assert_eq!(dag.get(sink)?, 500); // (100 * 2) + (100 * 3)
@@ -279,7 +282,8 @@ async fn test_massive_parallel_fanout() -> DagResult<()> {
.collect();
let start = Instant::now();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await?;
let elapsed = start.elapsed();
// All should complete
+3 -2
View File
@@ -1,7 +1,7 @@
//! Tests for timing and speedup verification
use dagx::{task, DagResult, DagRunner};
use futures::FutureExt;
use std::time::{Duration, Instant};
use tokio::time::sleep;
@@ -29,7 +29,8 @@ async fn test_parallel_execution_speedup() -> DagResult<()> {
.collect();
let start = Instant::now();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await?;
dag.run(|fut| async move { tokio::spawn(fut).await.unwrap() })
.await?;
let elapsed = start.elapsed();
// Verify all tasks completed