Actor API
Installation
SlowActors.SlowActors
— ModuleSlowActors
A minimal Julia actors library for using the Actors
interface.
It is not registered since it has demonstrative purpose. You can install it by:
pkg> add "https://github.com/JuliaActors/SlowActors.jl"
SlowActors.version
— ConstantGives the package version.
SlowActors
uses and reexports Actors
. So the functionality of Actors
is available to work with "slow" actors.
Starting Actors, creating Links
SlowActors
are actually a complete different implementation of actors than those in Actors
. They implement a Mailbox
type for communication. Slow actors don`t run in a loop listening to a channel, but are actually started as tasks when a message is sent to them.
But both libraries use a common Link{T}
for communication. The following functions for creating actors or links return Link{Mailbox}
as concrete type:
SlowActors.spawn
— Functionspawn(bhv::Func; sticky=false)
Create a new slow actor with a behavior bhv
. If sticky=true
it is started on the same thread as the sender of a message.
Note: a slow actor is actually started as a task if a message is sent to it.
SlowActors.newLink
— FunctionnewLink()
Create a mailbox (without an actor) which can be used to communicate with slow actors.
SlowActors
exports only those two functions.
Primitives
SlowActors reimplements actually only one actor primitive:
Actors.send!
— Functionsend!(lk::Link{Mailbox}, msg::Msg)
send!(lk::Link{Mailbox}, msg...)
Send a message msg
to a slow actor. Start it if it doesn't run.
Note: You must reeimplement those as methods of Actors.send!
.
The other actor primitives such as become!
or self
are plugged in from Actors
. See the source how that works.
User API
Likewise with the user API. SlowActors doesn't implement any user API functions but uses the message protocol of Actors
and thus gets the Actors
API.