Update non-default feature code

This commit is contained in:
TechnoPorg committed 2026-01-22 00:30:48 +01:00
1 parent 85ccd7e507
commit ee3c9f4417
6 files changed
+12 -14

No files matched your search

+1 -1
View File
@@ -28,7 +28,7 @@ unexpected_cfgs = { level = "warn", check-cfg = [
] } ] }
[dependencies] [dependencies]
futures = "0.3" futures = { version = "0.3", default-features = false, features = ["std"] }
parking_lot = "0.12" parking_lot = "0.12"
dagx-macros = { version = "0.3.1", path = "./dagx-macros" } dagx-macros = { version = "0.3.1", path = "./dagx-macros" }
tracing = { version = "0.1", optional = true } tracing = { version = "0.1", optional = true }
+1 -1
View File
@@ -284,7 +284,7 @@ impl DagRunner {
/// # }; /// # };
/// ``` /// ```
#[inline] #[inline]
#[cfg_attr(feature = "tracing", tracing::instrument(skip(self)))] #[cfg_attr(feature = "tracing", tracing::instrument(skip(self, spawner)))]
pub async fn run<S, F>(&self, spawner: S) -> DagResult<()> pub async fn run<S, F>(&self, spawner: S) -> DagResult<()>
where where
S: Fn(BoxFuture<'static, DagResult<(NodeId, Arc<dyn Any + Send + Sync>)>>) -> F, S: Fn(BoxFuture<'static, DagResult<(NodeId, Arc<dyn Any + Send + Sync>)>>) -> F,
+3 -3
View File
@@ -27,7 +27,7 @@ async fn test_basic_dag_async_std() {
let y = dag.add_task(Value(3)); let y = dag.add_task(Value(3));
let sum = dag.add_task(Add).depends_on((&x, &y)); let sum = dag.add_task(Add).depends_on((&x, &y));
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await.unwrap(); dag.run(|fut| async_std::task::spawn(fut)).await.unwrap();
assert_eq!(dag.get(sum).unwrap(), 5); assert_eq!(dag.get(sum).unwrap(), 5);
} }
@@ -40,7 +40,7 @@ async fn test_parallel_execution_async_std() {
.map(|i| dag.add_task(task_fn(move |_: ()| async move { i * 2 }))) .map(|i| dag.add_task(task_fn(move |_: ()| async move { i * 2 })))
.collect(); .collect();
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await.unwrap(); dag.run(|fut| async_std::task::spawn(fut)).await.unwrap();
for (i, task) in tasks.iter().enumerate() { for (i, task) in tasks.iter().enumerate() {
assert_eq!(dag.get(task).unwrap(), i * 2); assert_eq!(dag.get(task).unwrap(), i * 2);
@@ -58,7 +58,7 @@ async fn test_complex_dependencies_async_std() {
.add_task(task_fn(|x: i32| async move { x * 2 })) .add_task(task_fn(|x: i32| async move { x * 2 }))
.depends_on(sum); .depends_on(sum);
dag.run(|fut| tokio::spawn(fut).map(Result::unwrap)).await.unwrap(); dag.run(|fut| async_std::task::spawn(fut)).await.unwrap();
assert_eq!(dag.get(double).unwrap(), 60); assert_eq!(dag.get(double).unwrap(), 60);
} }
+3
View File
@@ -2,3 +2,6 @@
pub mod compatibility; pub mod compatibility;
pub mod quirky; pub mod quirky;
mod async_std;
mod smol;
+3 -9
View File
@@ -28,9 +28,7 @@ fn test_basic_dag_smol() {
let y = dag.add_task(Value(3)); let y = dag.add_task(Value(3));
let sum = dag.add_task(Add).depends_on((&x, &y)); let sum = dag.add_task(Add).depends_on((&x, &y));
dag.run(|fut| smol::spawn(fut).map(Result::unwrap)) dag.run(|fut| smol::spawn(fut)).await.unwrap();
.await
.unwrap();
assert_eq!(dag.get(sum).unwrap(), 5); assert_eq!(dag.get(sum).unwrap(), 5);
}); });
@@ -45,9 +43,7 @@ fn test_parallel_execution_smol() {
.map(|i| dag.add_task(task_fn(move |_: ()| async move { i * 2 }))) .map(|i| dag.add_task(task_fn(move |_: ()| async move { i * 2 })))
.collect(); .collect();
dag.run(|fut| smol::spawn(fut).map(Result::unwrap)) dag.run(|fut| smol::spawn(fut)).await.unwrap();
.await
.unwrap();
for (i, task) in tasks.iter().enumerate() { for (i, task) in tasks.iter().enumerate() {
assert_eq!(dag.get(task).unwrap(), i * 2); assert_eq!(dag.get(task).unwrap(), i * 2);
@@ -67,9 +63,7 @@ fn test_complex_dependencies_smol() {
.add_task(task_fn(|x: i32| async move { x * 2 })) .add_task(task_fn(|x: i32| async move { x * 2 }))
.depends_on(sum); .depends_on(sum);
dag.run(|fut| smol::spawn(fut).map(Result::unwrap)) dag.run(|fut| smol::spawn(fut)).await.unwrap();
.await
.unwrap();
assert_eq!(dag.get(double).unwrap(), 60); assert_eq!(dag.get(double).unwrap(), 60);
}); });
+1
View File
@@ -1,6 +1,7 @@
//! Tests with tracing feature enabled //! Tests with tracing feature enabled
use dagx::{task, DagRunner, Task}; use dagx::{task, DagRunner, Task};
use futures::FutureExt;
use tracing_subscriber::{fmt, EnvFilter}; use tracing_subscriber::{fmt, EnvFilter};
struct Value(i32); struct Value(i32);