MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ with_async() [1/2]

template<ComputeData StartType, typename ChainFunc , typename CompleteFn >
void MayaFlux::Yantra::ComputeMatrix::with_async ( Datum< StartType >  input,
ChainFunc &&  chain,
CompleteFn &&  on_complete 
)
inline

Execute an operation chain asynchronously.

chain receives a FluentExecutor seeded with input and must return the terminal Datum. The entire sequence runs on a background thread. on_complete is invoked with the result on that same thread.

The future is owned by this matrix instance. drain_async() and the destructor guarantee all in-flight chains finish before the matrix is destroyed. No thread management is required by the caller.

matrix->with_async(make_granular_input(container),
[](auto chain) {
return chain.then<SegmentOp>("segment")
.then<AttributeOp>("attribute")
.then<SortOp>("sort")
.to_io();
},
ex->grains = std::move(result);
ex->ready = true;
});
BufferProcessingChain * chain
Input/Output container for computation pipeline data flow with structure preservation.
Definition DataIO.hpp:26
Template Parameters
StartTypeInput data type.
ChainFuncCallable: (FluentExecutor<ComputeMatrix, StartType>) -> Datum<ResultType>.
CompleteFnCallable: (Datum<R>) -> void, where R is deduced from ChainFunc.
Parameters
inputSeed datum for the chain.
chainLambda describing the full operation sequence.
on_completeCalled with the final Datum on completion.

Definition at line 402 of file ComputeMatrix.hpp.

403 {
404 auto self = shared_from_this();
405 register_async(std::async(std::launch::async,
406 [self,
407 input = std::move(input),
408 chain = std::forward<ChainFunc>(chain),
409 on_complete = std::forward<CompleteFn>(on_complete)]() mutable {
410 on_complete(chain(
411 FluentExecutor<ComputeMatrix, StartType>(self, std::move(input))));
412 }));
413 }
Core::GlobalInputConfig input
Definition Config.cpp:42
void register_async(std::future< void > f)

References chain, and input.