Skip to content

Commit 7ea232a

Browse files
committed
move fallback fetch(::Any) to Base
fixes an item from #30945
1 parent a94f3d1 commit 7ea232a

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

base/task.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ function wait(t::Task)
192192
end
193193
end
194194

195+
fetch(@nospecialize x) = x
196+
195197
"""
196198
fetch(t::Task)
197199

stdlib/Distributed/docs/src/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Distributed.pmap
1818
Distributed.RemoteException
1919
Distributed.Future
2020
Distributed.RemoteChannel
21-
Distributed.fetch(::Any)
21+
Distributed.fetch(::Future)
22+
Distributed.fetch(::RemoteChannel)
2223
Distributed.remotecall(::Any, ::Integer, ::Any...)
2324
Distributed.remotecall_wait(::Any, ::Integer, ::Any...)
2425
Distributed.remotecall_fetch(::Any, ::Integer, ::Any...)

stdlib/Distributed/src/remotecall.jl

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,13 @@ Wait for a value to become available on the specified [`RemoteChannel`](@ref).
506506
"""
507507
wait(r::RemoteChannel, args...) = (call_on_owner(wait_ref, r, myid(), args...); r)
508508

509+
"""
510+
fetch(x::Future)
511+
512+
Wait for and get the value of a [`Future`](@ref). The fetched value is cached locally.
513+
Further calls to `fetch` on the same reference return the cached value. If the remote value
514+
is an exception, throws a [`RemoteException`](@ref) which captures the remote exception and backtrace.
515+
"""
509516
function fetch(r::Future)
510517
r.v !== nothing && return something(r.v)
511518
v = call_on_owner(fetch_ref, r)
@@ -515,22 +522,14 @@ function fetch(r::Future)
515522
end
516523

517524
fetch_ref(rid, args...) = fetch(lookup_ref(rid).c, args...)
518-
fetch(r::RemoteChannel, args...) = call_on_owner(fetch_ref, r, args...)
519525

520526
"""
521-
fetch(x)
527+
fetch(c::RemoteChannel)
522528
523-
Waits and fetches a value from `x` depending on the type of `x`:
524-
525-
* [`Future`](@ref): Wait for and get the value of a `Future`. The fetched value is cached locally.
526-
Further calls to `fetch` on the same reference return the cached value. If the remote value
527-
is an exception, throws a [`RemoteException`](@ref) which captures the remote exception and backtrace.
528-
* [`RemoteChannel`](@ref): Wait for and get the value of a remote reference. Exceptions raised are
529-
same as for a `Future` .
530-
531-
Does not remove the item fetched.
529+
Wait for and get a value from a [`RemoteChannel`](@ref). Exceptions raised are the
530+
same as for a `Future`. Does not remove the item fetched.
532531
"""
533-
fetch(@nospecialize x) = x
532+
fetch(r::RemoteChannel, args...) = call_on_owner(fetch_ref, r, args...)
534533

535534
isready(rv::RemoteValue, args...) = isready(rv.c, args...)
536535

0 commit comments

Comments
 (0)