From c82afce7b472217ce06e89106cd5ddaa825a44ff Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Mon, 4 Feb 2019 16:16:55 -0500 Subject: [PATCH] move fallback `fetch(::Any)` to Base fixes an item from #30945 --- base/task.jl | 2 ++ stdlib/Distributed/src/remotecall.jl | 23 +++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/base/task.jl b/base/task.jl index 4045cde09ffa15..500fb24c92c11b 100644 --- a/base/task.jl +++ b/base/task.jl @@ -192,6 +192,8 @@ function wait(t::Task) end end +fetch(@nospecialize x) = x + """ fetch(t::Task) diff --git a/stdlib/Distributed/src/remotecall.jl b/stdlib/Distributed/src/remotecall.jl index d2fbe75a9f2039..80b18153d4a7c9 100644 --- a/stdlib/Distributed/src/remotecall.jl +++ b/stdlib/Distributed/src/remotecall.jl @@ -506,6 +506,13 @@ Wait for a value to become available on the specified [`RemoteChannel`](@ref). """ wait(r::RemoteChannel, args...) = (call_on_owner(wait_ref, r, myid(), args...); r) +""" + fetch(x::Future) + +Wait for and get the value of a [`Future`](@ref). The fetched value is cached locally. +Further calls to `fetch` on the same reference return the cached value. If the remote value +is an exception, throws a [`RemoteException`](@ref) which captures the remote exception and backtrace. +""" function fetch(r::Future) r.v !== nothing && return something(r.v) v = call_on_owner(fetch_ref, r) @@ -515,22 +522,14 @@ function fetch(r::Future) end fetch_ref(rid, args...) = fetch(lookup_ref(rid).c, args...) -fetch(r::RemoteChannel, args...) = call_on_owner(fetch_ref, r, args...) """ - fetch(x) + fetch(c::RemoteChannel) -Waits and fetches a value from `x` depending on the type of `x`: - -* [`Future`](@ref): Wait for and get the value of a `Future`. The fetched value is cached locally. - Further calls to `fetch` on the same reference return the cached value. If the remote value - is an exception, throws a [`RemoteException`](@ref) which captures the remote exception and backtrace. -* [`RemoteChannel`](@ref): Wait for and get the value of a remote reference. Exceptions raised are - same as for a `Future` . - -Does not remove the item fetched. +Wait for and get a value from a [`RemoteChannel`](@ref). Exceptions raised are the +same as for a `Future`. """ -fetch(@nospecialize x) = x +fetch(r::RemoteChannel, args...) = call_on_owner(fetch_ref, r, args...) isready(rv::RemoteValue, args...) = isready(rv.c, args...)