MCPcopy Create free account
hub / github.com/microsoft/typescript-go / createRelease

Method createRelease

internal/project/checkerpool.go:345–378  ·  view source on GitHub ↗
(requestID string, index int, c *checker.Checker)

Source from the content-addressed store, hash-verified

343}
344
345func (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

Callers 3

getDiagnosticsCheckerMethod · 0.95
getQueryCheckerMethod · 0.95

Calls 9

disposeCheckerLockedMethod · 0.95
scheduleCleanupLockedMethod · 0.95
holdTagFunction · 0.85
WasCanceledMethod · 0.80
logMethod · 0.65
NowMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected