Starting Actors, creating links

Actors.jl doesn't export its functions to start actors and to create links. Thus other libraries building on it can implement their own actors and links.

To use Actors's actors and links you import them explicitly:

using Actors
import Actors: spawn, newLink

Then you can create them with the following functions:

ActorInterfaces.Classic.spawnFunction
spawn(f, args...; 
      pid=myid(), thrd=false, sticky=false, 
      taskref=nothing, remote=false, mode=:default)

Create an actor with a behavior f(args...) and return a Link to it.

Parameters

  • f: callable object (function, closure or functor) to execute when a message arrives,
  • args...: (partial) arguments to it,
  • pid=nothing: pid of worker process the actor should be started on, if nothing the actor is started on myid(),
  • thrd=false: thread number the actor should be started on or false,
  • sticky=false: if true the actor is started on the current thread,
  • taskref=nothing: if a Ref{Task}() is given here, it gets the started Task,
  • remote=false: if true, a remote channel is created,
  • mode=:default: mode, the actor should operate in.

Note: If you need keyword arguments kwargs... to f, you can do spawn(Bhv(f, args...; kwargs...)).

source
Actors.newLinkFunction
newLink(size=32; remote=false, pid=myid(), mode=nothing)

Create a local Link with a buffered Channel size ≥ 1.

Parameters

  • size=32: the size of the channel buffer,
  • remote=false: should a remote link be created,
  • pid=myid(): optional pid of the remote worker,
  • mode=nothing: if mode==nothing the mode is automatically set to :local or :remote.
source