Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/workerpool.jl
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,28 @@ function CachingPool(workers::Vector{Int})
return pool
end

"""
CachingPool(func, workers::Vector{Int})

Excute `func(pool)`, clearing out any cached functions from the workers when complete.

# Examples
```julia
CachingPool(workers()) do wp
foo = rand(10^8);
pmap(wp, i -> sum(foo) + i, 1:100);
end
"""
function CachingPool(func, workers::Vector{Int})
pool = CachingPool(workers)
try
func(pool)
finally
clear!(pool)
end
end


"""
clear!(pool::CachingPool) -> pool

Expand Down