Skip to content

Commit f5a50be

Browse files
matbesanconStefanKarpinski
authored andcommitted
Future doc (#31737)
1 parent 073cbbb commit f5a50be

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

stdlib/Distributed/src/remotecall.jl

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ const client_refs = WeakKeyDict{Any, Nothing}() # used as a WeakKeySet
1313
abstract type AbstractRemoteRef end
1414

1515
"""
16-
Future(pid::Integer=myid())
16+
Future(w::Int, rrid::RRID, v::Union{Some, Nothing}=nothing)
1717
18-
Create a `Future` on process `pid`.
19-
The default `pid` is the current process.
18+
A `Future` is a placeholder for a single computation
19+
of unknown termination status and time.
20+
For multiple potential computations, see `RemoteChannel`.
21+
See `remoteref_id` for identifying an `AbstractRemoteRef`.
2022
"""
2123
mutable struct Future <: AbstractRemoteRef
2224
where::Int
@@ -98,9 +100,15 @@ function finalize_ref(r::AbstractRemoteRef)
98100
nothing
99101
end
100102

103+
"""
104+
Future(pid::Integer=myid())
105+
106+
Create a `Future` on process `pid`.
107+
The default `pid` is the current process.
108+
"""
109+
Future(pid::Integer=myid()) = Future(pid, RRID())
101110
Future(w::LocalProcess) = Future(w.id)
102111
Future(w::Worker) = Future(w.id)
103-
Future(pid::Integer=myid()) = Future(pid, RRID())
104112

105113
RemoteChannel(pid::Integer=myid()) = RemoteChannel{Channel{Any}}(pid, RRID())
106114

@@ -177,9 +185,12 @@ If the argument `Future` is owned by a different node, this call will block to w
177185
It is recommended to wait for `rr` in a separate task instead
178186
or to use a local [`Channel`](@ref) as a proxy:
179187
180-
c = Channel(1)
181-
@async put!(c, remotecall_fetch(long_computation, p))
182-
isready(c) # will not block
188+
```julia
189+
p = 1
190+
f = Future(p)
191+
@async put!(f, remotecall_fetch(long_computation, p))
192+
isready(f) # will not block
193+
```
183194
"""
184195
function isready(rr::Future)
185196
rr.v === nothing || return true
@@ -232,7 +243,7 @@ function del_clients(pairs::Vector)
232243
end
233244
end
234245

235-
any_gc_flag = Condition()
246+
const any_gc_flag = Condition()
236247
function start_gc_msgs_task()
237248
@async while true
238249
wait(any_gc_flag)

0 commit comments

Comments
 (0)