Skip to content

Commit

Permalink
Move some spawn related macro docs out of HelpDB (#22573)
Browse files Browse the repository at this point in the history
* Move some spawn related macro docs out of HelpDB
  • Loading branch information
kshyatt authored Jul 1, 2017
1 parent 244b889 commit b5a61db
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 16 deletions.
69 changes: 69 additions & 0 deletions base/distributed/macros.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,52 @@ spawnat(p, thunk) = sync_add(remotecall(thunk, p))

spawn_somewhere(thunk) = spawnat(nextproc(),thunk)

"""
@spawn
Create a closure around an expression and run it on an automatically-chosen process,
returning a [`Future`](@ref) to the result.
# Examples
```julia-repl
julia> addprocs(3);
julia> f = @spawn myid()
Future(2, 1, 5, Nullable{Any}())
julia> fetch(f)
2
julia> f = @spawn myid()
Future(3, 1, 7, Nullable{Any}())
julia> fetch(f)
3
```
"""
macro spawn(expr)
thunk = esc(:(()->($expr)))
:(spawn_somewhere($thunk))
end

"""
@spawnat
Create a closure around an expression and run the closure
asynchronously on process `p`. Returns a [`Future`](@ref) to the result.
Accepts two arguments, `p` and an expression.
# Examples
```julia-repl
julia> addprocs(1);
julia> f = @spawnat 2 myid()
Future(2, 1, 3, Nullable{Any}())
julia> fetch(f)
2
```
"""
macro spawnat(p, expr)
thunk = esc(:(()->($expr)))
:(spawnat($(esc(p)), $thunk))
Expand All @@ -31,6 +72,23 @@ end
Equivalent to `fetch(@spawn expr)`.
See [`fetch`](@ref) and [`@spawn`](@ref).
# Examples
```julia-repl
julia> addprocs(3);
julia> @fetch myid()
2
julia> @fetch myid()
3
julia> @fetch myid()
4
julia> @fetch myid()
2
```
"""
macro fetch(expr)
thunk = esc(:(()->($expr)))
Expand All @@ -42,6 +100,17 @@ end
Equivalent to `fetch(@spawnat p expr)`.
See [`fetch`](@ref) and [`@spawnat`](@ref).
# Examples
```julia-repl
julia> addprocs(3);
julia> @fetchfrom 2 myid()
2
julia> @fetchfrom 4 myid()
4
```
"""
macro fetchfrom(p, expr)
thunk = esc(:(()->($expr)))
Expand Down
16 changes: 0 additions & 16 deletions base/docs/helpdb/Base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -454,14 +454,6 @@ application/postscript) or `x::Vector{UInt8}` (for binary MIME types).
"""
display

"""
@spawnat
Accepts two arguments, `p` and an expression. A closure is created around the expression and
run asynchronously on process `p`. Returns a [`Future`](@ref) to the result.
"""
:@spawnat

"""
print_shortest(io, x)
Expand Down Expand Up @@ -1903,14 +1895,6 @@ Maintains order and multiplicity of the first argument for arrays and ranges.
"""
intersect

"""
@spawn
Creates a closure around an expression and runs it on an automatically-chosen process,
returning a [`Future`](@ref) to the result.
"""
:@spawn

"""
promote_rule(type1, type2)
Expand Down

2 comments on commit b5a61db

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

Please sign in to comment.