Don't clone task inputs

This commit is contained in:
TechnoPorg committed 2026-02-11 22:29:54 +01:00
1 parent 6f7a58e4c5
commit 4ef7e69cdd
10 files changed
+15 -137

No files matched your search

+4 -8
View File
@@ -5,8 +5,8 @@
//! **NOTE**: This module is now primarily for internal use. The `ExtractInput` trait is only
//! used by the internal `task_fn` test helper function.
//!
//! **For regular tasks**: The `#[task]` macro generates inline `extract_and_run()` methods with
//! type-specific extraction logic. This means **ANY type** implementing `Clone + Send + Sync`
//! **For regular tasks**: The `#[task]` macro generates inline `run()` methods with
//! type-specific extraction logic. This means **ANY type** implementing `Send + Sync`
//! works automatically without needing `ExtractInput` implementations!
//!
//! # How it works
@@ -15,8 +15,8 @@
//! Outputs are wrapped in Arc for efficient fanout (cheap Arc clones instead of data clones).
//!
//! **Modern approach (via `#[task]` macro)**:
//! - The macro generates custom extraction logic inline in `extract_and_run()`
//! - Works with ANY type (just needs `Clone + Send + Sync`)
//! - The macro generates custom extraction logic inline in `run()`
//! - Works with ANY type (just needs `Send + Sync + 'static`)
//! - No trait implementations needed!
//!
//! **Legacy approach (via `ExtractInput` trait)**:
@@ -40,10 +40,6 @@ use crate::TaskInput;
///
/// Type erasure occurs only at the ExecutableNode trait boundary - by the time
/// we're in ExtractInput, we know the concrete type and can safely downcast.
///
/// NOTE: This trait is now primarily used by the internal `task_fn` test helper.
/// The `#[task]` macro generates inline extraction logic via `extract_and_run()`,
/// which allows ANY type to work without requiring ExtractInput implementations.
#[allow(dead_code)]
pub trait ExtractInput: Sized + Clone {
type Input: Send;
+2 -4
View File
@@ -11,7 +11,7 @@
//! system. The public API is fully type-safe with no runtime type errors. Internal execution
//! uses type erasure for heterogeneous task storage, but this is never exposed to users.
//! - **Works with ANY type**: Custom types work automatically with the `#[task]` macro—just
//! implement `Clone + Send + Sync`, no trait implementations needed! The macro generates
//! implement `Send + Sync`, no trait implementations needed! The macro generates
//! type-specific extraction logic for seamless integration.
//! - **Runtime-agnostic**: Works with any async runtime (Tokio, async-std, smol, Embassy, etc.)
//! - **Type-state pattern**: The API guides you with compile-time errors if you wire dependencies
@@ -442,15 +442,13 @@
//!
//! ## Custom Types
//!
//! **dagx works with ANY type automatically!** As long as your type implements `Clone + Send + Sync + 'static`,
//! **dagx works with ANY type automatically!** As long as your type is `Send + Sync + 'static`,
//! the `#[task]` macro generates the necessary extraction logic:
//!
//! ```no_run
//! # use dagx::{task, DagRunner, Task};
//! # use futures::FutureExt;
//!
//! // Just derive Clone - that's all you need!
//! #[derive(Clone)]
//! struct User {
//! name: String,
//! age: u32,
+1 -1
View File
@@ -70,7 +70,7 @@ where
dependencies: Vec<Arc<dyn Any + Send + Sync>>,
) -> ExecuteFuture {
Box::pin(async move {
// Use the task's extract_and_run method which has inline extraction logic
// Use the task's run method which has inline extraction logic
// generated by the #[task] macro. This allows ANY type to work without
// requiring ExtractInput trait implementations.
let output = self.task.run(TaskInput::new(dependencies.iter())).await;
-3
View File
@@ -527,9 +527,6 @@ impl DagRunner {
/// - The task hasn't been executed yet
/// - The handle is invalid
///
/// Returns `DagError::TaskPanicked` if:
/// - A task executing in the
///
/// # Examples
///
/// ```no_run
+2 -2
View File
@@ -11,10 +11,10 @@ use crate::extract::ExtractInput;
///
/// Use the [`task`](crate::task) macro to implement this trait. The macro automatically
/// derives `Input` and `Output` types from your `run()` method signature and generates
/// type-specific extraction logic in `extract_and_run()`.
/// type-specific extraction logic in `run()`.
///
/// **Custom types work automatically!** As long as your output type implements
/// `Clone + Send + Sync + 'static`, the macro handles everything. No trait implementations needed!
/// `Send + Sync + 'static`, the macro handles everything. No trait implementations needed!
///
/// # Task Patterns
///