GenServers
API
Installation
GenServers.GenServers
— ModuleGenServers
Implements a generic server Actors
protocol.
It lets you write an implementation module with a user API for a server and callback functions which are called by the server if certain requests are issued.
It lets you write purely sequential code while the :genserver
actor cares about the concurrency and distributed part. This simplifies greatly the development of servers.
The current stable, registered version is installed with
pkg> add GenServers
The development version is installed with:
pkg> add "https://github.com/JuliaActors/GenServers.jl"
GenServers.version
— ConstantGives the package version.
julia> using GenServers
julia> GenServers.version
v"0.2.0"
Starting a Server
A :genserver actor usually is started with something it should serve, e.g. files, a printer, a dictionary ...
GenServers.genserver
— Functiongenserver(m::Module, args...; name=nothing,
pid=myid(), thrd=false,
sticky=false, taskref=nothing)
Create an actor in :genserver
mode. It uses the callbacks in a user provided module m
when processing messages.
Arguments
m::Module
: a user provided module in current scope,args...
: arguments to the user providedinit
callback.
Keyword Arguments
name=nothing
: if aname::Symbol
is provided the server is registered and the name is returned,pid=myid()
: worker pid to create the actor on,thrd=false
: thread to create the actor on,sticky=false
: iftrue
, the actor is created in the same thread,taskref=nothing
: if aRef{Task}
variable is provided, it gets the createdTask
.