Skip to content

Commit ff8637d

Browse files
committed
@Shard: Construct shards in parallel
1 parent cec17a1 commit ff8637d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Diff for: src/chunks.jl

+6-2
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,15 @@ function shard(@nospecialize(f); procs=nothing, workers=nothing, per_thread=fals
197197
end
198198
end
199199
isempty(procs) && throw(ArgumentError("Cannot create empty Shard"))
200-
shard_dict = Dict{Processor,Chunk}()
200+
shard_running_dict = Dict{Processor,EagerThunk}()
201201
for proc in procs
202202
scope = proc isa OSProc ? ProcessScope(proc) : ExactScope(proc)
203203
thunk = Dagger.@spawn scope=scope _mutable_inner(f, proc, scope)
204-
shard_dict[proc] = fetch(thunk)[]
204+
shard_running_dict[proc] = thunk
205+
end
206+
shard_dict = Dict{Processor,Chunk}()
207+
for proc in procs
208+
shard_dict[proc] = fetch(shard_running_dict[proc])[]
205209
end
206210
return Shard(shard_dict)
207211
end

0 commit comments

Comments
 (0)