Skip to content

Commit

Permalink
doc AbstractWorkerPool
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyatt committed Apr 9, 2019
1 parent 1b57e3a commit 6cbd7a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions stdlib/Distributed/docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Distributed.put!(::Future, ::Any)
Distributed.take!(::RemoteChannel, ::Any...)
Distributed.isready(::RemoteChannel, ::Any...)
Distributed.isready(::Future)
Distributed.AbstractWorkerPool
Distributed.WorkerPool
Distributed.CachingPool
Distributed.default_worker_pool
Expand Down
29 changes: 16 additions & 13 deletions stdlib/Distributed/src/workerpool.jl
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# This file is a part of Julia. License is MIT: https://julialang.org/license

abstract type AbstractWorkerPool end
"""
AbstractWorkerPool
# An AbstractWorkerPool should implement
#
# `push!` - add a new worker to the overall pool (available + busy)
# `put!` - put back a worker to the available pool
# `take!` - take a worker from the available pool (to be used for remote function execution)
# `length` - number of workers available in the overall pool
# `isready` - return false if a `take!` on the pool would block, else true
#
# The default implementations of the above (on a AbstractWorkerPool) require fields
# channel::Channel{Int}
# workers::Set{Int}
#
Supertype for worker pools such as [`WorkerPool`](@ref) and [`CachingPool`](@ref).
An `AbstractWorkerPool` should implement:
- [`push!`](@ref) - add a new worker to the overall pool (available + busy)
- [`put!`](@ref) - put back a worker to the available pool
- [`take!`](@ref) - take a worker from the available pool (to be used for remote function execution)
- [`length`](@ref) - number of workers available in the overall pool
- [`isready`](@ref) - return false if a `take!` on the pool would block, else true
The default implementations of the above (on a `AbstractWorkerPool`) require fields
channel::Channel{Int}
workers::Set{Int}
where `channel` contains free worker pids and `workers` is the set of all workers associated with this pool.
"""
abstract type AbstractWorkerPool end

mutable struct WorkerPool <: AbstractWorkerPool
channel::Channel{Int}
Expand Down

0 comments on commit 6cbd7a8

Please sign in to comment.