Skip to content

Commit

Permalink
don't wait unnecessarily for items to end up in the channel
Browse files Browse the repository at this point in the history
  • Loading branch information
MasonProtter committed Jan 31, 2024
1 parent 54cdcc9 commit f5380d1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/implementation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ function _tmapreduce_greedy(f, op, Arrs, ::Type{OutputType}, nchunks, split, map
nchunks > 0 || throw("Error: nchunks must be a positive integer")
if Base.IteratorSize(first(Arrs)) isa Base.SizeUnknown
ntasks = nchunks
ch_len = 0
else
check_all_have_same_indices(Arrs)
ntasks = min(length(first(Arrs)), nchunks)
ch_len = length(first(Arrs))
end
ch = Channel{Tuple{eltype.(Arrs)...}}(0; spawn=true) do ch
ch = Channel{Tuple{eltype.(Arrs)...}}(ch_len; spawn=true) do ch
for args zip(Arrs...)
put!(ch, args)
end
Expand Down

0 comments on commit f5380d1

Please sign in to comment.