How about swapping the value of `local` and `g` atomically? There'd be no need to change the refcounts because they just exchange the ownership at the same time. The destruction can be deferred.
- Nim 2: "Memory can be shared effectively between threads ... planetis
- Nim 2: "Memory can be shared effectively between threads ... planetis
- Nim 2: "Memory can be shared effectively between threads ... Araq
- Nim 2: "Memory can be shared effectively between threads ... PMunch
- Nim 2: "Memory can be shared effectively between threads ... zevv
- Nim 2: "Memory can be shared effectively between threads ... Araq
- Nim 2: "Memory can be shared effectively between threads ... PMunch
- Nim 2: "Memory can be shared effectively between threads ... Araq
- Nim 2: "Memory can be shared effectively between threads ... ElegantBeef
- Nim 2: "Memory can be shared effectively between threads ... PMunch
- Nim 2: "Memory can be shared effectively between threads ... sls1005
- Nim 2: "Memory can be shared effectively between threads ... PMunch
- Nim 2: "Memory can be shared effectively between threads ... sls1005
- Nim 2: "Memory can be shared effectively between threads ... zevv
- Nim 2: "Memory can be shared effectively between threads ... Araq
- Nim 2: "Memory can be shared effectively between threads ... zevv
- Nim 2: "Memory can be shared effectively between threads ... zevv
- Nim 2: "Memory can be shared effectively between threads ... Araq
- Nim 2: "Memory can be shared effectively between threads ... zevv
- Nim 2: "Memory can be shared effectively between threads ... Araq