tryReuseIdleAssigned returns an already-assigned, idle (Hot) worker of the requested shape with its session count bumped, or nil if none is available.
(profile *WorkerProfile)
| 302 | // WorkerCount returns the number of workers this CP currently has assigned to |
| 303 | // the org that count against MaxWorkers (hot-idle workers are excluded — they're |
| 304 | // parked for reclaim and don't consume the cap budget, same as atOrgWorkerCap). |
| 305 | // This is the per-CP local view; the admin layer sums it across replicas (a |
| 306 | // worker is owned by exactly one CP) for the Overview per-org load bar. |
| 307 | func (p *OrgReservedPool) WorkerCount() int { |
| 308 | p.shared.mu.Lock() |
| 309 | defer p.shared.mu.Unlock() |
| 310 | return p.assignedWorkerCountLocked() |
| 311 | } |
| 312 | |
| 313 | // tryReuseIdleAssigned returns an already-assigned, idle (Hot) worker of the |
| 314 | // requested shape with its session count bumped, or nil if none is available. |
| 315 | func (p *OrgReservedPool) tryReuseIdleAssigned(profile *WorkerProfile) *ManagedWorker { |
| 316 | p.shared.mu.Lock() |
| 317 | defer p.shared.mu.Unlock() |
| 318 | if p.shared.shuttingDown { |
| 319 | return nil |
| 320 | } |
| 321 | p.shared.cleanDeadWorkersLocked() |
| 322 | idle := p.findIdleAssignedWorkerLocked(profile) |
| 323 | if idle == nil { |
no test coverage detected