1. I think you will be surprised when you benchmark this. ;-)
  2. There is also a different solution:


    
    
    proc incRef(x: ptr ObjectHeader) =
      # bit 0 indicates if shared:
      if (x.rc and 1) == 1: atomicInc(x.rc, 2)
      else: inc(x.rc, 2)
    
    
    Run

But then you need to mark the full transitive ref-graph before passing it to a 
different thread. Could be an experiment worth trying though.

3\. Keep in mind that this is only a dangling ref detector, so you can cheat 
and not count refs on the stack. There is some paper justifying this approach 
but I'm too lazy to dig it out again, see the big RFC here: 
[https://github.com/nim-lang/RFCs/issues/144](https://github.com/nim-lang/RFCs/issues/144)

Reply via email to