From 454ce22eb6b6e9a35727e645f40a33a245aa62f0 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Fri, 27 Aug 2021 15:24:15 +0900 Subject: [PATCH 1/3] improve atomic docs --- base/docs/basedocs.jl | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index d9625c914633b..a7b8a3ac8a1ed 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -2003,24 +2003,23 @@ setfield! These atomically perform the operations to simultaneously get and set a field: - y = getfield!(value, name) + y = getfield(value, name) setfield!(value, name, x) return y -``` """ swapfield! """ - modifyfield!(value, name::Symbol, op, x, [order::Symbol]) - modifyfield!(value, i::Int, op, x, [order::Symbol]) + modifyfield!(value, name::Symbol, op, x, [order::Symbol]) -> Pair{<:Any,: Pair{<:Any,: z If supported by the hardware (for example, atomic increment), this may be optimized to the appropriate hardware instruction, otherwise it'll use a loop. @@ -2029,18 +2028,19 @@ modifyfield! """ replacefield!(value, name::Symbol, expected, desired, - [success_order::Symbol, [fail_order::Symbol=success_order]) => - (old, Bool) + [success_order::Symbol, [fail_order::Symbol=success_order]) -> NamedTuple{(:old, :success), Tuple{<:Any, Bool}} + replacefield!(value, i::Int, expected, desired, + [success_order::Symbol, [fail_order::Symbol=success_order]) -> NamedTuple{(:old, :success), Tuple{<:Any, Bool}} These atomically perform the operations to get and conditionally set a field to a given value. - y = getfield!(value, name, fail_order) + y = getfield(value, name, fail_order) ok = y === expected if ok setfield!(value, name, desired, success_order) end - return y, ok + return (; old = y, success = ok) If supported by the hardware, this may be optimized to the appropriate hardware instruction, otherwise it'll use a loop. From 5f3e9093123f94c9b5ac1dcae2cb65b5f5e163f9 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com> Date: Sat, 28 Aug 2021 08:45:46 +0900 Subject: [PATCH 2/3] Update base/docs/basedocs.jl Co-authored-by: Jameson Nash --- base/docs/basedocs.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index a7b8a3ac8a1ed..29a73142dd3b6 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -2010,8 +2010,8 @@ These atomically perform the operations to simultaneously get and set a field: swapfield! """ - modifyfield!(value, name::Symbol, op, x, [order::Symbol]) -> Pair{<:Any,: Pair{<:Any,: Pair + modifyfield!(value, i::Int, op, x, [order::Symbol]) -> Pair These atomically perform the operations to get and set a field after applying the function `op`. From 32936f56df3f194f76b880b811e3d055834ce093 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com> Date: Sat, 28 Aug 2021 14:35:14 +0900 Subject: [PATCH 3/3] Update base/docs/basedocs.jl Co-authored-by: Jameson Nash --- base/docs/basedocs.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base/docs/basedocs.jl b/base/docs/basedocs.jl index 29a73142dd3b6..9338095dc0ac8 100644 --- a/base/docs/basedocs.jl +++ b/base/docs/basedocs.jl @@ -2028,9 +2028,9 @@ modifyfield! """ replacefield!(value, name::Symbol, expected, desired, - [success_order::Symbol, [fail_order::Symbol=success_order]) -> NamedTuple{(:old, :success), Tuple{<:Any, Bool}} + [success_order::Symbol, [fail_order::Symbol=success_order]) -> (; old, success::Bool) replacefield!(value, i::Int, expected, desired, - [success_order::Symbol, [fail_order::Symbol=success_order]) -> NamedTuple{(:old, :success), Tuple{<:Any, Bool}} + [success_order::Symbol, [fail_order::Symbol=success_order]) -> (; old, success::Bool) These atomically perform the operations to get and conditionally set a field to a given value.