diff options
author | Araq <rumpf_a@web.de> | 2020-05-12 20:12:55 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2020-05-12 20:13:06 +0200 |
commit | 82f008158cbc023c5e20103bfb4bda317be52fb2 (patch) | |
tree | ab03cb1f31922a864f1bf082cfec7d6a7cc675ef | |
parent | 09ea8f9cf8ee796bdd5f8a803d30216e7aefa6ba (diff) | |
download | Nim-82f008158cbc023c5e20103bfb4bda317be52fb2.tar.gz |
cycle collector: make it threadsafe
-rw-r--r-- | lib/system/cyclicrefs_bacon.nim | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/system/cyclicrefs_bacon.nim b/lib/system/cyclicrefs_bacon.nim index aeee6e3d9..5f0197384 100644 --- a/lib/system/cyclicrefs_bacon.nim +++ b/lib/system/cyclicrefs_bacon.nim @@ -89,15 +89,15 @@ proc nimTraceRefDyn(q: pointer; env: pointer) {.compilerRtl.} = j.traceStack.add(head p[], cast[ptr PNimType](p[])[]) var - roots: CellSeq + roots {.threadvar.}: CellSeq proc unregisterCycle(s: Cell) = # swap with the last element. O(1) let idx = s.rootIdx - if idx >= roots.len or idx < 0: - cprintf("[Bug!] %ld\n", idx) - quit 1 - + when false: + if idx >= roots.len or idx < 0: + cprintf("[Bug!] %ld\n", idx) + quit 1 roots.d[idx] = roots.d[roots.len-1] roots.d[idx][0].rootIdx = idx dec roots.len |