mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-08 14:03:23 +00:00
cycle collector: make it threadsafe
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user