MCPcopy Index your code
hub / github.com/coder/coder / releaseRunRef

Function releaseRunRef

coderd/x/chatd/chatdebug/recorder.go:128–143  ·  view source on GitHub ↗

releaseRunRef decrements the reference count for runID and cleans up shared state when the last reference is released. The mutex ensures no concurrent trackRunRef can increment between the zero check and the map deletions.

(runID uuid.UUID)

Source from the content-addressed store, hash-verified

126// no concurrent trackRunRef can increment between the zero check and
127// the map deletions.
128func releaseRunRef(runID uuid.UUID) {
129 refCountMu.Lock()
130 defer refCountMu.Unlock()
131 val, ok := runRefCounts.Load(runID)
132 if !ok {
133 return
134 }
135 counter, ok := val.(*atomic.Int32)
136 if !ok {
137 panic("chatdebug: runRefCounts contains non-*atomic.Int32 value")
138 }
139 if counter.Add(-1) <= 0 {
140 runRefCounts.Delete(runID)
141 stepCounters.Delete(runID)
142 }
143}
144
145func nextStepNumber(runID uuid.UUID) int32 {
146 val, _ := stepCounters.LoadOrStore(runID, &atomic.Int32{})

Callers 1

ContextWithRunFunction · 0.85

Calls 5

AddMethod · 0.65
DeleteMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45
LoadMethod · 0.45

Tested by

no test coverage detected