Skip to content

Commit f14e50b

Browse files
aviateskvtjnash
authored andcommitted
improve atomic docs (#42024)
* improve atomic docs * Update base/docs/basedocs.jl Co-authored-by: Jameson Nash <[email protected]> * Update base/docs/basedocs.jl Co-authored-by: Jameson Nash <[email protected]> Co-authored-by: Jameson Nash <[email protected]> (cherry picked from commit f916b94)
1 parent e609a27 commit f14e50b

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

base/docs/basedocs.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,24 +1980,23 @@ setfield!
19801980
19811981
These atomically perform the operations to simultaneously get and set a field:
19821982
1983-
y = getfield!(value, name)
1983+
y = getfield(value, name)
19841984
setfield!(value, name, x)
19851985
return y
1986-
```
19871986
"""
19881987
swapfield!
19891988

19901989
"""
1991-
modifyfield!(value, name::Symbol, op, x, [order::Symbol])
1992-
modifyfield!(value, i::Int, op, x, [order::Symbol])
1990+
modifyfield!(value, name::Symbol, op, x, [order::Symbol]) -> Pair
1991+
modifyfield!(value, i::Int, op, x, [order::Symbol]) -> Pair
19931992
19941993
These atomically perform the operations to get and set a field after applying
19951994
the function `op`.
19961995
1997-
y = getfield!(value, name)
1996+
y = getfield(value, name)
19981997
z = op(y, x)
19991998
setfield!(value, name, z)
2000-
return y, z
1999+
return y => z
20012000
20022001
If supported by the hardware (for example, atomic increment), this may be
20032002
optimized to the appropriate hardware instruction, otherwise it'll use a loop.
@@ -2006,18 +2005,19 @@ modifyfield!
20062005

20072006
"""
20082007
replacefield!(value, name::Symbol, expected, desired,
2009-
[success_order::Symbol, [fail_order::Symbol=success_order]) =>
2010-
(old, Bool)
2008+
[success_order::Symbol, [fail_order::Symbol=success_order]) -> (; old, success::Bool)
2009+
replacefield!(value, i::Int, expected, desired,
2010+
[success_order::Symbol, [fail_order::Symbol=success_order]) -> (; old, success::Bool)
20112011
20122012
These atomically perform the operations to get and conditionally set a field to
20132013
a given value.
20142014
2015-
y = getfield!(value, name, fail_order)
2015+
y = getfield(value, name, fail_order)
20162016
ok = y === expected
20172017
if ok
20182018
setfield!(value, name, desired, success_order)
20192019
end
2020-
return y, ok
2020+
return (; old = y, success = ok)
20212021
20222022
If supported by the hardware, this may be optimized to the appropriate hardware
20232023
instruction, otherwise it'll use a loop.

0 commit comments

Comments
 (0)