-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
To accommodate the use-cases specified in #5 (comment), here is my proposed alternative:
https://github.com/planetis-m/dumpster/blob/master/expsmarts.nim#L18-L30
type
SharedPtr*[T] = object
## Shared ownership reference counting pointer.
deleter*: Deleter[T]
val*: ptr Payload[T]
proc `=destroy`*[T](p: var SharedPtr[T]) =
if p.val != nil:
if p.val.counter.load(Consume) == 0:
`=destroy`(p.val.value)
if p.deleter != nil:
p.deleter(p.val[])
else:
atomicDec(p.val.counter)Can the deleter field be removed somehow?
Every field must be exported, so that libraries can provide their implementations like this:
https://github.com/planetis-m/dumpster/blob/master/pools.nim#L24
Opinions? @arnetheduck, @timotheecour, @Araq
Metadata
Metadata
Assignees
Labels
No labels