After watching the JuliaCon talk on Transducers.jl, I started to wonder about multiple cases where iterators are not optimal. One of the instances that seem suited for transducers are the systems with a feedback loop.
Let’s consider an intelligent algorithm (or a person ;D) which by learning the unknown function
f(x) in the evaluation would schedule optimal values on which to evaluate the function. The algorithm could also take into account unresolved (not yet evaluated) points to schedule new ones and so enabling parallelism .
So far, by learning the Transducers.jl I came up with a code:
using Transducers l = Learner() # the data for the intelligent algorithm which has ask!=iterate and tell! methods. jobsch = Channel(TakeWhile(x->npoints(l)<10 && while unresolved(l)>4 sleep(1) end),l) resch = Channel(Map(x->(x,x^2)),jobsch) foreach(Map(identity),resch) do input @show input tell!(l,input) end
It is unclear to me how the evaluation from
resch happens. Does
Transducers.jl create a separate loop for this transformation? If so, is it threaded? How to execute it parallel instead?
I also wonder if there is a better way to express waiting, which is now that dirty while loop.
: Some time ago, I implemented the model with iterators in TaskMaster.jl