At the suggestion of @axsk <https://github.com/axsk> I tried this again but 
using a SharedArray instead of a channel and it seems to be working now. I 
am curious as to why my approach didn't work, if anyone cares to explain.

(I'm on v0.4.3)

On Tuesday, March 8, 2016 at 6:56:39 AM UTC-7, michael wrote:
>
> I'm fairly new to parallel processing but I'm trying to use Channels in a 
> way I think is consistent with the documentation but I may be 
> misinterpreting it. I've explained in more detail in a StackOverflow post 
> <https://stackoverflow.com/questions/35787324/functionality-of-take-and-put-and-channels-in-julia>
>  but 
> essentially what I'm trying to do is have an integer variable that several 
> processes can access and, if one returns an integer smaller than that 
> variable, can update. The general approach is something like this:
>
> x = Channel{Int64}(1)
> put!(x,n)
>
> @everywhere function f(item,chan)
>     going = true
>     count = 0
>     while(going)
>         going = false
>         # perform some operations
>         if (count < fetch(chan) && !conditions_met())
>             # conditions_met checks the other termination conditions
>             going = true
>             count += 1
>         end
>     end
>
>     count += 1
>
>     if (count < fetch(chan))
>         take!(chan)
>         put!(chan,count)
>     end
>
>     return count
> end
>
> y = @parallel (min) for i in collection
>     f(i,x)
> end
>
> Am I correct in my logic? Is this something I should be able to do?
>

Reply via email to