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

Method tryAcquire

coderd/x/chatd/chatadvisor/runtime.go:146–156  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144}
145
146func (rt *Runtime) tryAcquire() bool {
147 for {
148 used := rt.used.Load()
149 if used >= int64(rt.cfg.MaxUsesPerRun) {
150 return false
151 }
152 if rt.used.CompareAndSwap(used, used+1) {
153 return true
154 }
155 }
156}
157
158// release returns a previously acquired use to the pool. Callers must
159// invoke this at most once per successful tryAcquire when the advisor

Callers 1

RunAdvisorMethod · 0.95

Calls 2

CompareAndSwapMethod · 0.80
LoadMethod · 0.45

Tested by

no test coverage detected