Distributed: Calling a remote method on remote global

distributed

#1

using Distributed
addprocs(1)

# Define a simple function:
@everywhere x2(x) = x^2;

# Create a float on the remote worker:
x = 5.0;
remotecall_fetch(()->x, 2);
remotecall_fetch(varinfo, 2)

# Change x on the main process and verify it has not changed on the remote process:
x = 100
remotecall_fetch(varinfo, 2)

How would I update the value of x on the worker process using function x2()? In other words, how to use x2() to update x to be 25.0 on the worker without transferring x through the main process?

In case additional context helps, the actual goal is:

The worker process collects regular data updates from a remote source. With each update it produces an output (call it VEC) which it sends to a function on the main process. This function (call it MAINFUNC) updates a variable (call it MYSTRUCT) that exists as a global on the main process. I would like the worker to be able to call MAINFUNC on the main process providing VEC and MYSTRUCT as arguments (where VEC exists on the worker and MYSTRUCT exists on the main process).

Any insights greatly appreciated - thank you!