Skip to content

Commit 3f605ce

Browse files
authored
Prefer the original logic over simplification
1 parent 68fc921 commit 3f605ce

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Diff for: threading/smartptrs.nim

+3-1
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ type
8181

8282
proc `=destroy`*[T](p: var SharedPtr[T]) =
8383
if p.val != nil:
84-
if fetchSub(p.val[].counter, 1, AcqRel) == 0:
84+
if p.val[].counter.load(Acquire) == 0:
8585
`=destroy`(p.val[])
8686
deallocShared(p.val)
87+
else:
88+
discard fetchSub(p.val[].counter, 1, Release)
8789

8890
proc `=copy`*[T](dest: var SharedPtr[T], src: SharedPtr[T]) =
8991
if src.val != nil:

0 commit comments

Comments
 (0)