We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5fcec8b commit 68fc921Copy full SHA for 68fc921
threading/smartptrs.nim
@@ -81,15 +81,13 @@ type
81
82
proc `=destroy`*[T](p: var SharedPtr[T]) =
83
if p.val != nil:
84
- if p.val[].counter.load(Consume) == 0:
+ if fetchSub(p.val[].counter, 1, AcqRel) == 0:
85
`=destroy`(p.val[])
86
deallocShared(p.val)
87
- else:
88
- atomicDec(p.val[].counter)
89
90
proc `=copy`*[T](dest: var SharedPtr[T], src: SharedPtr[T]) =
91
if src.val != nil:
92
- atomicInc(src.val[].counter)
+ discard fetchAdd(src.val[].counter, 1, Relaxed)
93
if dest.val != nil:
94
`=destroy`(dest)
95
dest.val = src.val
0 commit comments