Skip to content

Commit

Permalink
Some more examples/formatting/xrefs for Distributed docs (#29011)
Browse files Browse the repository at this point in the history
(cherry picked from commit 448bc7d)
  • Loading branch information
kshyatt authored and KristofferC committed Feb 11, 2019
1 parent ed7ee4a commit 6795469
Showing 1 changed file with 77 additions and 9 deletions.
86 changes: 77 additions & 9 deletions stdlib/Distributed/src/cluster.jl
Original file line number Diff line number Diff line change
Expand Up @@ -720,13 +720,33 @@ const map_del_wrkr = Set{Int}()
myid()
Get the id of the current process.
# Examples
```julia-repl
julia> myid()
1
julia> remotecall_fetch(() -> myid(), 4)
4
```
"""
myid() = LPROC.id

"""
nprocs()
Get the number of available processes.
# Examples
```julia-repl
julia> nprocs()
3
julia> workers()
5-element Array{Int64,1}:
2
3
```
"""
function nprocs()
if myid() == 1 || (PGRP.topology == :all_to_all && !isclusterlazy())
Expand All @@ -746,8 +766,19 @@ end
"""
nworkers()
Get the number of available worker processes. This is one less than `nprocs()`. Equal to
Get the number of available worker processes. This is one less than [`nprocs()`](@ref). Equal to
`nprocs()` if `nprocs() == 1`.
# Examples
```julia-repl
\$ julia -p 5
julia> nprocs()
6
julia> nworkers()
5
```
"""
function nworkers()
n = nprocs()
Expand All @@ -757,7 +788,18 @@ end
"""
procs()
Return a list of all process identifiers.
Return a list of all process identifiers, including pid 1 (which is not included by [`workers()`](@ref)).
# Examples
```julia-repl
\$ julia -p 5
julia> procs()
3-element Array{Int64,1}:
1
2
3
```
"""
function procs()
if myid() == 1 || (PGRP.topology == :all_to_all && !isclusterlazy())
Expand Down Expand Up @@ -809,6 +851,16 @@ end
workers()
Return a list of all worker process identifiers.
# Examples
```julia-repl
\$ julia -p 5
julia> workers()
2-element Array{Int64,1}:
2
3
```
"""
function workers()
allp = procs()
Expand All @@ -832,13 +884,29 @@ Remove the specified workers. Note that only process 1 can add or remove
workers.
Argument `waitfor` specifies how long to wait for the workers to shut down:
- If unspecified, `rmprocs` will wait until all requested `pids` are removed.
- An `ErrorException` is raised if all workers cannot be terminated before
the requested `waitfor` seconds.
- With a `waitfor` value of 0, the call returns immediately with the workers
scheduled for removal in a different task. The scheduled `Task` object is
returned. The user should call `wait` on the task before invoking any other
parallel calls.
- If unspecified, `rmprocs` will wait until all requested `pids` are removed.
- An [`ErrorException`](@ref) is raised if all workers cannot be terminated before
the requested `waitfor` seconds.
- With a `waitfor` value of 0, the call returns immediately with the workers
scheduled for removal in a different task. The scheduled [`Task`](@ref) object is
returned. The user should call [`wait`](@ref) on the task before invoking any other
parallel calls.
# Examples
```julia-repl
\$ julia -p 5
julia> t = rmprocs(2, 3, waitfor=0)
Task (runnable) @0x0000000107c718d0
julia> wait(t)
julia> workers()
3-element Array{Int64,1}:
4
5
6
```
"""
function rmprocs(pids...; waitfor=typemax(Int))
cluster_mgmt_from_master_check()
Expand Down

0 comments on commit 6795469

Please sign in to comment.