(requestID string, index int, c *checker.Checker)
| 343 | } |
| 344 | |
| 345 | func (p *checkerPool) createRelease(requestID string, index int, c *checker.Checker) func() { |
| 346 | return sync.OnceFunc(func() { |
| 347 | p.mu.Lock() |
| 348 | |
| 349 | if c.WasCanceled() { |
| 350 | // Canceled checkers must be disposed. |
| 351 | p.log(fmt.Sprintf("checkerpool: Checker %d for request %s was canceled, disposing", index, holdTag(requestID))) |
| 352 | p.disposeCheckerLocked(index, c) |
| 353 | } else { |
| 354 | p.mergeGlobalDiagnosticsFromCheckerLocked(index, c) |
| 355 | p.heldBy[index] = "" |
| 356 | p.lastReleased[index] = time.Now() |
| 357 | if !p.discarded { |
| 358 | p.scheduleCleanupLocked() |
| 359 | } |
| 360 | // If discarded, skip scheduling cleanup — checkers stay alive |
| 361 | // until the pool is garbage collected so that API clients can |
| 362 | // continue resolving type/symbol handles. |
| 363 | } |
| 364 | |
| 365 | // Unlock before releasing the semaphore slot. If we received from |
| 366 | // the channel while holding p.mu, a woken goroutine could immediately |
| 367 | // try to acquire p.mu, risking priority inversion or unnecessary |
| 368 | // contention. |
| 369 | p.mu.Unlock() |
| 370 | |
| 371 | // Release the semaphore slot. |
| 372 | if index == 0 { |
| 373 | <-p.diagSem |
| 374 | } else { |
| 375 | <-p.querySem |
| 376 | } |
| 377 | }) |
| 378 | } |
| 379 | |
| 380 | // registerRequestCleanup uses context.AfterFunc to delete the request |
| 381 | // association when the request context is done. This prevents the map |
no test coverage detected