Guards API
Guards.Guards
— ModuleGuards
Implements a generic server Actor's protocol.
The current stable, registered version is installed with
pkg> add Guards
The development version is installed with:
pkg> add "https://github.com/JuliaActors/Guards.jl"
Guards.version
— ConstantGives the package version.
Guards.Guard
— TypeGuard{T}
A parametric struct returned by guard
.
Parameter/Field
T
: the type of the guarded variable,link::Union{Link,Symbol}
:Link
or name of guard actor.
Actors.call
— Methodcall(gd::Guard [, lk::Link])
Call a guard actor gd
to respond with a deep copy of the guarded variable var
.
Arguments
Arguments
gd::Guard
: link to the:guard
actor,lk::Link
: if a linklk
is provided send the response to that, else do a synchronousrequest
,
Actors.call
— Methodcall(gd::Guard, [lk::Link,] f::Function, args...)
Call a guard actor gd
to execute f(var, args...)
on its guarded variable var
and to respond with a deep copy of the result.
Arguments
gd::Guard
: link to the:guard
actor,lk::Link
: if a linklk
is provided send the response to that, else do a synchronousrequest
,f
: function taking the guarded variablevar
as first argument,args...
: further arguments tof
.
Actors.cast
— Methodcast(gd::Guard, f, args...)
Cast a message to a guard actor gd
to execute f(var, args...)
on its guarded variable var.
Arguments
gd::Guard
: link to the:guard
actor,f
: callable object taking the guarded variablevar
as first argument,args...
: further arguments tof
.
Actors.update!
— Methodupdate!(gd::Guard, var)
Update a guarded variable represented by gd
with var
.
Note: var
must be of the same type as the guarded variable!
Guards.guard
— Methodguard(var; name=nothing, pid=myid(), thrd=false,
sticky=false, taskref=nothing)
Start a :guard
actor for the variable var
and return a Guard
link to it.
Parameters
var
: variable to guard for,name=nothing
: if aname::Symbol
is provided the server is registered and the name is returned,remote=false
: ifremote=true
a guard with an remote link 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
.
Guards.@grd
— Macro@grd f(gd, args...)
Execute a function f
on a guarded variable var
represented by an actor link gd
and return a deep copy of the result or return a deep copy of var
. This is a wrapper to call
.
@grd gd
Return a deep copy of the guarded variable.
Parameters
gd::Guard
: a link to the:guard
actor,f
: callable object taking the guarded variablevar
as first argument,args...
: further arguments tof
.