isready
isready(r::RemoteRef)
Determine whether a RemoteRef
has a value stored to it. Note that this function can cause race conditions, since by the time you receive its result it may no longer be true. It is recommended that this function only be used on a RemoteRef
that is assigned once.
If the argument RemoteRef
is owned by a different node, this call will block to wait for the answer. It is recommended to wait for r
in a separate task instead, or to use a local RemoteRef
as a proxy:
rr = RemoteRef()
@async put!(rr, remotecall_fetch(long_computation, p))
isready(rr) # will not block
Examples
julia> r = RemoteRef()
RemoteRef{Channel{Any}}(1, 1, 2)
julia> isready(r)
false
In this example, the isready
function is used to check if a RemoteRef
has a value stored to it. Initially, the RemoteRef
r
does not have a value stored, so isready(r)
returns false
.
julia> rr = RemoteRef(p, Channel{Any}(true))
julia> isready(rr)
true
This example demonstrates that if the RemoteRef
has a value stored, the isready
function returns true
.
Note that using isready
can cause race conditions since the result may not be accurate by the time it is received. It is recommended to use isready
on a RemoteRef
that is assigned once. If the RemoteRef
is owned by a different node, the call to isready
will block to wait for the answer. It is better to wait for the RemoteRef
in a separate task or use a local RemoteRef
as a proxy to avoid blocking.
See Also
accept, bind, :@spawn, connect, fetch, getaddrinfo, gethostname, getipaddr, getsockname, init_worker, IPv4, IPv6, isready, issocket, kill, listen, recv, recvfrom, remotecall, remotecall_fetch, remotecall_wait, RemoteRef, send, setopt,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.