Skip to main content

define_task

Macro define_task 

Source
define_task!() { /* proc-macro */ }
Expand description

Generates async-mpc task implementations with automatic dependency management.

This macro takes a struct definition and a compute function, and generates:

  • An internal unresolved struct to hold task dependencies
  • A public type alias using the TaskWrapper type
  • A Task trait implementation with async execution logic
  • A new constructor for creating new task instances
  • A standalone compute method for direct calls

ยงExamples

define_task! {
    pub struct FieldAddTask<F: FieldExtension> {
        x: Arc<dyn Task<Output = Arc<FieldShare<F>>>>,
        y: Arc<dyn Task<Output = Arc<FieldShare<F>>>>,
    }

    async fn compute(x: FieldShare<F>, y: FieldShare<F>) -> Result<FieldShare<F>, AbortError> {
        Ok(x + &y)
    }
}