# Transducers, paralelism and feedback loop

**URL:** https://discourse.julialang.org/t/transducers-paralelism-and-feedback-loop/28189
**Category:** Performance
**Tags:** parallel, multithreading
**Created:** [August 29, 2019, 11:39pm UTC](https://discourse.julialang.org/t/transducers-paralelism-and-feedback-loop/28189 "2019-08-29T23:39:32Z")
**Posts on this page:** 1
**Showing post:** 7

<div class="post-metadata">

### Author: ![Janis\_Erdmanis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/janis_erdmanis/32/10869_2.png) [@Janis\_Erdmanis](https://discourse.julialang.org/u/Janis_Erdmanis)
#### Post date: [October 7, 2019, 4:48pm UTC](https://discourse.julialang.org/t/transducers-paralelism-and-feedback-loop/28189/7 "2019-10-07T16:48:26Z")

</div>

> [@tkf](#):
>
> Having said that, it may be useful if you want to fuse pre- and post- processings with learning. It would be great if you can explore this area because I’ve never tried. But I don’t want to blindly encourage this direction as there is a chance that it may not be as fruitful as you would have hoped.

I just finalised the design of the TaskMaster.jl package which takes inputs and puts outputs in the channels. I thought that it would be trivial to couple them also with transducers, but it just halts. The relevant code:

```julia
using Distributed
addprocs(2)
using TaskMaster
using Transducers

@everywhere f(x) = x^2

master = ProcMaster(f)
learner = IgnorantLearner(1:10)
loop = Loop(master,learner)

@sync begin
    inch = Channel(Map(identity),1:10)
    outch = Channel(1)
    @async evaluate(loop,inch,outch)

    for o in outch
        @show o
    end
    ### Gets stuck at the first element
    collect(Map(identity),outch)
end

```

To see how I use `evaluate(loop,inch,outch)` [see evaluate.jl file on the GitHub](https://github.com/akels/TaskMaster.jl/blob/master/src/evaluate.jl).

It would also be aesthetically pleasing if I could couple `Loop` with transducers with `|>`. So, for example, I could do:

```julia
collect(Map(identity) |> Loop(master,learner) |> Map(identity),1:10)

```

Also, it seems easily possible to initiate `Master` with transducer instead of a function with channels. Not sure how that would be useful. Maybe it would allow modelling electrical circuits.

---

_[View the full topic](https://discourse.julialang.org/t/transducers-paralelism-and-feedback-loop/28189)._
