Remove clone bound from task data

This commit is contained in:
TechnoPorg committed 2026-02-11 21:59:41 +01:00
1 parent 064c2a15be
commit 0137296fb4
9 files changed
+233 -442

No files matched your search

+6 -15
View File
@@ -12,8 +12,7 @@ use std::pin::Pin;
use std::sync::Arc;
use crate::error::DagError;
use crate::task::Task;
use crate::types::NodeId;
use crate::task::{Task, TaskInput};
/// Type-erased async execution result (Arc-wrapped for efficient fanout)
type ExecuteFuture =
@@ -52,20 +51,19 @@ pub(crate) trait ExecutableNode: Send {
///
/// The output is also returned from execute_with_deps for central storage.
pub(crate) struct TypedNode<T: Task> {
pub(crate) id: NodeId,
pub(crate) task: T,
}
impl<T: Task + 'static> TypedNode<T> {
pub(crate) fn new(id: NodeId, task: T) -> Self {
Self { id, task }
pub(crate) fn new(task: T) -> Self {
Self { task }
}
}
impl<T: Task + 'static> ExecutableNode for TypedNode<T>
where
T::Input: 'static + Clone,
T::Output: 'static + Clone,
T::Input: 'static,
T::Output: 'static,
{
fn execute_with_deps(
self: Box<Self>,
@@ -75,14 +73,7 @@ where
// Use the task's extract_and_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 = match self.task.extract_and_run(dependencies).await {
Ok(output) => output,
Err(_msg) => {
// Failed to extract input - likely type mismatch.
// This should technically be infallible, so it might be worth removing in the future.
return Err(DagError::InvalidDependency { task_id: self.id.0 });
}
};
let output = self.task.run(TaskInput::new(dependencies.iter())).await;
// Arc Wrapping Strategy:
// Wrap output in Arc ONCE for efficient fan-out sharing.