June 2019
Intermediate to advanced
218 pages
5h 19m
English
@spawn is a simpler way to run a function in a remote process without having to specify the remote node or having to work through ambiguous syntax:
julia> a=@spawn randn(5,5)^2Future(2, 1, 32, nothing)julia> fetch(a)5×5 Array{Float64,2}: 3.47542 1.97838 -3.37651 -0.370807 -0.402992 1.35532 -2.29925 3.69952 0.74422 4.75399 -0.148023 -1.50948 2.5483 0.562872 2.04142 2.65948 0.59873 -3.55425 -1.22119 2.56416 0.122034 -1.86732 0.172352 -1.64478 2.12055
This macro actually creates a closure around the code being called on the remote node. This means that any variable declared on the current node will be copied over to the remote node. In the preceding code, the random array is created on the remote node. However, in the following ...
Read now
Unlock full access