Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update parallel.rst #10277

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions doc/stdlib/parallel.rst
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ General Parallel Computing Support

Fetch the value of a remote reference, removing it so that the reference is empty again.

procList = addprocs(1) # add another process
rr = RemoteRef(procList[1]) # create a remote reference on the next process
@everywhere function f(inRR::RemoteRef)
x = take!(inRR)
put!(inRR, x ^ 2)
end
@spawnat procList[1] f(rr)
put!(rr, 8)
@show( take!(rr) ) # => 64
Copy link
Contributor

Choose a reason for hiding this comment

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

Though the chances of seeing a return value of 8 here is almost nil, julia does not guarantee that f will execute on the remote worker before the take! here.

Hence, a better example for message passing would be to have two remote refs, say r1 and r2. r1 is always written to from the local process and read from the remote process, while r2 is always written to at the remote process and read from the local.

put!(rr, 8)
@show( take!(rr) ) # => 8

.. function:: isready(r::RemoteRef)

Determine whether a ``RemoteRef`` has a value stored to it. Note that this function
Expand Down