-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathRemoteSpawn.tex
8 lines (5 loc) · 996 Bytes
/
RemoteSpawn.tex
1
2
3
4
5
6
7
8
\section{Remote Spawning of Actors \experimental}
\label{remote-spawn}
Remote spawning is an extension of the dynamic spawn using run-time type names \see{add-custom-actor-type}. The following example assumes a typed actor handle named \lstinline^calculator^ with an actor implementing this messaging interface named "calculator".
\lstinputlisting[linerange={125-143}]{../examples/remoting/remote_spawn.cpp}
We first connect to a CAF node with \lstinline^middleman().connect(host, port)^. On success, \lstinline^connect^ returns the node ID we need for \lstinline^remote_spawn^. This requires the server to open a port with \lstinline^middleman().open(port)^ or \lstinline^middleman().publish(..., port)^. Alternatively, we can obtain the node ID from an already existing remote actor handle---returned from \lstinline^remote_actor^ for example---via \lstinline^hdl->node()^. After connecting to the server, we can use \lstinline^middleman().remote_spawn<...>(...)^ to create actors remotely.