Below you can find some confusion I had earlier. Is there a reason that Threads.foreach
can’t take an array?
Previous confusion
Can someone explain why this code isn’t printing each element of the array?
julia> function make_ch(arr)
@show "in make"
return Channel() do ch
@show "in channel" arr
Threads.foreach(arr) do e
@show "in foreach"
@show e
end
@show "exiting channel"
end
end
make_ch (generic function with 1 method)
julia> make_ch(collect(1:10))
"in make" = "in make"
"in channel" = "in channel"
arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Channel{Any}(0) (closed)
julia> versioninfo()
Julia Version 1.10.0-beta2
Commit a468aa198d (2023-08-17 06:27 UTC)
Build Info:
Official https://julialang.org/ release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-15.0.7 (ORCJIT, tigerlake)
Threads: 11 on 8 virtual cores
Environment:
JULIA_EDITOR = code
I thought I had my code working on 1.10.0-beta1 and now it is broken after upgrade. This MWE makes me think there might be a bug? But I might be totally missing something.
PS, it works when I switch to regular foreach