Guards API

Guards.GuardsModule
Guards

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"
source
Guards.GuardType
Guard{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.
source
Actors.callMethod
call(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 link lk is provided send the response to that, else do a synchronous request,
source
Actors.callMethod
call(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 link lk is provided send the response to that, else do a synchronous request,
  • f: function taking the guarded variable var as first argument,
  • args...: further arguments to f.
source
Actors.castMethod
cast(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 variable var as first argument,
  • args...: further arguments to f.
source
Actors.update!Method
update!(gd::Guard, var)

Update a guarded variable represented by gd with var.

Note: var must be of the same type as the guarded variable!

source
Guards.guardMethod
guard(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 a name::Symbol is provided the server is registered and the name is returned,
  • remote=false: if remote=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: if true, the actor is created in the same thread,
  • taskref=nothing: if a Ref{Task} variable is provided, it gets the created Task.
source
Guards.@grdMacro
@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 variable var as first argument,
  • args...: further arguments to f.
source