Skip to content

JuliaConcurrent/Atomix.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

eb24b95 · Feb 27, 2025

History

55 Commits
Jan 25, 2025
Nov 23, 2024
Nov 23, 2024
Jan 25, 2025
May 7, 2022
Jan 25, 2025
May 7, 2022
Nov 6, 2024
Sep 26, 2021
Feb 27, 2025
May 7, 2022

Repository files navigation

Atomix

Dev CI

Atomix.jl implements @atomic, @atomicswap, and @atomicreplace that are superset of the macros in Base. In addition to atomic operations on the fields as implemented in Base, they support atomic operations on array elements.

julia> using Atomix: @atomic, @atomicswap, @atomicreplace

julia> A = ones(Int, 3);

julia> @atomic A[1] += 1;  # fetch-and-increment

julia> @atomic A[1]
2

julia> @atomicreplace A[begin+1] 1 => 42  # compare-and-swap
(old = 1, success = true)

julia> @inbounds @atomic :monotonic A[begin+1]  # specify ordering and skip bound check
42

julia> @atomicswap A[end] = 123
1

julia> A[end]
123