Skip to content

Commit 0baf655

Browse files
committed
fix bug in @atomic order
Thanks vtjnash! #45 (comment)
1 parent 50d2398 commit 0baf655

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Perms/perm_images.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ function Base.copy(p::Perm)
4747
if isdefined(p, :inv, :sequentially_consistent)
4848
inv_imgs = copy(@atomic(p.inv).images)
4949
q⁻¹ = typeof(p)(inv_imgs; check = false)
50-
@atomic q.inv = q⁻¹
5150
@atomic q⁻¹.inv = q
51+
@atomic q.inv = q⁻¹
5252
end
5353
return q
5454
end
@@ -59,11 +59,11 @@ function Base.inv(σ::Perm)
5959
@atomic σ.inv = σ
6060
else
6161
σ⁻¹ = typeof(σ)(invperm.images); check = false)
62-
# we don't want to end up with two copies of inverse σ floating around
63-
if !isdefined(σ, :inv, :sequentially_consistent)
64-
@atomic σ.inv = σ⁻¹
65-
@atomic σ⁻¹.inv = σ
66-
end
62+
# this order is important:
63+
# fuly initialize the "local" inverse first and only then
64+
# update σ to make the local inverse visible globally
65+
@atomic σ⁻¹.inv = σ
66+
@atomic σ.inv = σ⁻¹
6767
end
6868
end
6969
return σ.inv

0 commit comments

Comments
 (0)