I have a pipeline of two functions that are both IO-heavy, running on a collection of items concurrently.
The first, func1
, is very common, and often I just want the response of func1
alone. Other times, I'd like to process the result of func1
with some other function, func2
.
What are the trade-offs (performance/overhead, idiomatic-ness) between composing Task.async_stream, i.e.
enum
|> Task.async_stream(Mod1, :func1, [])
|> Task.async_stream(Mod2, :func2, [])
...
vs. passing a continuation and using one Task.async_stream for both func1
and func2
i.e.
enum
|> Task.async_stream(Mod1, :func1_then, [&Mod2.func2/arity])
...
where func1_then
calls the function parameter (Mod2.func2
) at the end of the normal func1
computation?