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.spawn
— Functionspawn(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, ifnothing
the actor is started onmyid()
,thrd=false
: thread number the actor should be started on orfalse
,sticky=false
: iftrue
the actor is started on the current thread,taskref=nothing
: if aRef{Task}()
is given here, it gets the startedTask
,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...))
.
Actors.newLink
— FunctionnewLink(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
.