Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions base/expr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ result into the field in the first argument and return the values `(old, new)`.
This operation translates to a `modifyproperty!(a.b, :x, func, arg2)` call.


See [atomics](#man-atomics) in the manual for more details.
See [Per-field atomics](@ref man-atomics) section in the manual for more details.

```jldoctest
julia> mutable struct Atomic{T}; @atomic x::T; end
Expand Down Expand Up @@ -534,6 +534,9 @@ julia> @atomic max(a.x, 10) # change field x of a to the max value, with sequent
julia> @atomic a.x max 5 # again change field x of a to the max value, with sequential consistency
10 => 10
```

!!! compat "Julia 1.7"
This functionality requires at least Julia 1.7.
"""
macro atomic(ex)
if !isa(ex, Symbol) && !is_expr(ex, :(::))
Expand Down Expand Up @@ -601,7 +604,7 @@ Stores `new` into `a.b.x` and returns the old value of `a.b.x`.

This operation translates to a `swapproperty!(a.b, :x, new)` call.

See [atomics](#man-atomics) in the manual for more details.
See [Per-field atomics](@ref man-atomics) section in the manual for more details.

```jldoctest
julia> mutable struct Atomic{T}; @atomic x::T; end
Expand All @@ -615,6 +618,9 @@ julia> @atomicswap a.x = 2+2 # replace field x of a with 4, with sequential cons
julia> @atomic a.x # fetch field x of a, with sequential consistency
4
```

!!! compat "Julia 1.7"
This functionality requires at least Julia 1.7.
"""
macro atomicswap(order, ex)
order isa QuoteNode || (order = esc(order))
Expand Down Expand Up @@ -644,7 +650,7 @@ replacement was completed.

This operation translates to a `replaceproperty!(a.b, :x, expected, desired)` call.

See [atomics](#man-atomics) in the manual for more details.
See [Per-field atomics](@ref man-atomics) section in the manual for more details.

```jldoctest
julia> mutable struct Atomic{T}; @atomic x::T; end
Expand All @@ -669,6 +675,9 @@ julia> @atomicreplace a.x xchg
julia> @atomic a.x # fetch field x of a, with sequential consistency
0
```

!!! compat "Julia 1.7"
This functionality requires at least Julia 1.7.
"""
macro atomicreplace(success_order, fail_order, ex, old_new)
fail_order isa QuoteNode || (fail_order = esc(fail_order))
Expand Down
3 changes: 3 additions & 0 deletions doc/src/manual/multi-threading.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ orderings (:monotonic, :acquire, :release, :acquire\_release, or
with an atomic ordering constraint, or will be done with monotonic (relaxed)
ordering if unspecified.

!!! compat "Julia 1.7"
Per-field atomics requires at least Julia 1.7.


## Side effects and mutable function arguments

Expand Down