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

Method scheduleCleanupLocked

internal/project/checkerpool.go:396–424  ·  view source on GitHub ↗

scheduleCleanupLocked resets (or starts) the cleanup timer so it fires at the earliest pending checker-expiration deadline among all currently idle, unheld checkers. Must be called with p.mu held. Must NOT be called on discarded pools.

()

Source from the content-addressed store, hash-verified

394// unheld checkers.
395// Must be called with p.mu held. Must NOT be called on discarded pools.
396func (p *checkerPool) scheduleCleanupLocked() {
397 var earliestDeadline time.Time
398 for i := range p.checkers {
399 if p.checkers[i] == nil || p.heldBy[i] != "" || p.lastReleased[i].IsZero() {
400 continue
401 }
402 deadline := p.lastReleased[i].Add(p.opts.IdleTimeout)
403 if earliestDeadline.IsZero() || deadline.Before(earliestDeadline) {
404 earliestDeadline = deadline
405 }
406 }
407 if earliestDeadline.IsZero() {
408 // No idle checkers remain — stop the timer if it exists.
409 if p.cleanupTimer != nil {
410 p.cleanupTimer.Stop()
411 p.cleanupTimer = nil
412 }
413 return
414 }
415 delay := time.Until(earliestDeadline)
416 if delay <= 0 {
417 delay = time.Millisecond
418 }
419 if p.cleanupTimer != nil {
420 p.cleanupTimer.Reset(delay)
421 } else {
422 p.cleanupTimer = time.AfterFunc(delay, p.cleanupIdleCheckers)
423 }
424}
425
426// cleanupIdleCheckers disposes checkers that have been idle for longer than
427// the idle timeout. The API checker is separate and never idle-cleaned.

Callers 2

createReleaseMethod · 0.95
cleanupIdleCheckersMethod · 0.95

Calls 4

StopMethod · 0.80
AddMethod · 0.65
IsZeroMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected