Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/juliaactors/guards.jl
Actors guarding access to mutable variables
https://github.com/juliaactors/guards.jl
actor-framework actors concurrency concurrent-programming
Last synced: about 2 months ago
JSON representation
Actors guarding access to mutable variables
- Host: GitHub
- URL: https://github.com/juliaactors/guards.jl
- Owner: JuliaActors
- License: mit
- Created: 2020-12-01T06:35:38.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T17:47:26.000Z (over 3 years ago)
- Last Synced: 2024-11-09T08:00:04.723Z (about 2 months ago)
- Topics: actor-framework, actors, concurrency, concurrent-programming
- Language: Julia
- Homepage:
- Size: 194 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Guards
Let actors guard your mutable variables!
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://JuliaActors.github.io/Guards.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://JuliaActors.github.io/Guards.jl/dev)
[![Build Status](https://github.com/JuliaActors/Guards.jl/workflows/CI/badge.svg)](https://github.com/JuliaActors/Guards.jl/actions)
[![Coverage](https://codecov.io/gh/JuliaActors/Guards.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/JuliaActors/Guards.jl)With `Guards` you can wrap mutable variables into a `:guard` actor. That way they can be safely accessed from parallel threads and distributed worker processes via message passing.
## Example
```julia
julia> using Guardsjulia> gd = guard([1,2,3]) # start a guards actor around an array
Guards.Guard{Array{Int64,1}}(Link{Channel{Any}}(Channel{Any}(sz_max:32,sz_curr:0), 1, :guard))julia> call(gd) # get a deep copy of it
3-element Array{Int64,1}:
1
2
3julia> push!(call(gd), 4) # pushing to it ...
4-element Array{Int64,1}:
1
2
3
4julia> call(gd) # the guarded variable has not changed
3-element Array{Int64,1}:
1
2
3julia> call(gd, push!, 4); # if you call it with push!,
julia> @grd gd # ... it got changed (here using the @grd macro)
4-element Array{Int64,1}:
1
2
3
4julia> @grd pop!(gd) # pop! with the macro
4julia> update!(gd, [5,6,7,8])
4-element Array{Int64,1}:
5
6
7
8julia> @grd gd
4-element Array{Int64,1}:
5
6
7
8
````Guards` is part of [`JuliaActors`](https://github.com/JuliaActors).
## Author(s)
- Paul Bayer
**License:** MIT