@@ -44,36 +44,36 @@ AP.__unsafe_image(n::Integer, σ::Perm) = oftype(n, @inbounds σ.images[n])
4444function Base. copy (p:: Perm )
4545 imgs = copy (p. images)
4646 q = typeof (p)(imgs; check = false )
47- if isdefined (p, :inv , :sequentially_consistent )
48- inv_imgs = copy (@atomic ( p. inv) . images)
47+ if isdefined (p, :inv , :acquire )
48+ inv_imgs = copy (p. inv. images)
4949 q⁻¹ = typeof (p)(inv_imgs; check = false )
50- @atomic q . inv = q⁻¹
51- @atomic q⁻¹ . inv = q
50+ @atomic :release q⁻¹ . inv = q
51+ @atomiconce :release :acquire q . inv = q⁻¹
5252 end
5353 return q
5454end
5555
5656function Base. inv (σ:: Perm )
57- if ! isdefined (σ, :inv , :sequentially_consistent )
57+ if ! isdefined (σ, :inv , :acquire )
5858 if isone (σ)
59- @atomic σ. inv = σ
59+ @atomiconce :release :acquire σ. 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 :release σ⁻¹. inv = σ
66+ @atomiconce :release :acquire σ . inv = σ⁻¹
6767 end
6868 end
6969 return σ. inv
7070end
7171
7272function AP. cycles (σ:: Perm )
73- if ! isdefined (σ, :cycles , :sequentially_consistent )
73+ if ! isdefined (σ, :cycles , :acquire )
7474 cdec = AP. CycleDecomposition (σ)
7575 # we can afford producing more than one cycle decomposition
76- @atomic σ. cycles = cdec
76+ @atomiconce :release :acquire σ. cycles = cdec
7777 end
7878 return σ. cycles
7979end
0 commit comments