Make AbstractWorkerPool methods thread-safe and more consistent #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously they did not handle dead workers in the same way. In particular
take!
would remove dead workers but none of the other methods did, leading to cases whereisready
might return true buttake!
would still block.Now they should all be consistent with each other; except for
wait
which will block if the pool is empty, unliketake!
which will throw an exception. This seems like a reasonable tradeoff to minimize breakage while still ensuring that 'take!() will block if wait() blocks' holds.In theory one could put the dead worker checks in other methods like
length
andput!
, but the checks would still need to be intake!
/isready
etc so it seems simpler to just acknowledge the lack of thread-safety in these methods upfront.Fixes JuliaLang/Distributed.jl#87. If this is merged I'll backport it to Distributed.