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

Method scheduleIdleCacheClean

internal/project/session.go:539–568  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

537const idleCacheCleanDelay = 30 * time.Second
538
539func (s *Session) scheduleIdleCacheClean() {
540 s.idleCacheCleanMu.Lock()
541 defer s.idleCacheCleanMu.Unlock()
542
543 if s.idleCacheCleanTimer != nil {
544 s.idleCacheCleanTimer.Stop()
545 }
546
547 s.idleCacheCleanTimer = time.AfterFunc(idleCacheCleanDelay, func() {
548 s.idleCacheCleanMu.Lock()
549 s.idleCacheCleanTimer = nil
550 s.idleCacheCleanMu.Unlock()
551
552 s.snapshotUpdateMu.Lock()
553 defer s.snapshotUpdateMu.Unlock()
554 s.cancelScheduledSnapshotUpdate()
555
556 ctx := s.backgroundCtx
557 fileChanges, overlays, ataChanges, newConfig := s.flushChanges(ctx)
558 s.UpdateSnapshot(ctx, overlays, SnapshotChange{
559 reason: UpdateReasonIdleCleanDiskCache,
560 fileChanges: fileChanges,
561 ataChanges: ataChanges,
562 newConfig: newConfig,
563 cleanDiskCache: true,
564 })
565
566 go func() { runtime.GC() }()
567 })
568}
569
570func (s *Session) cancelIdleCacheClean() {
571 s.idleCacheCleanMu.Lock()

Callers 5

DidOpenFileMethod · 0.95
DidCloseFileMethod · 0.95
DidChangeFileMethod · 0.95
DidSaveFileMethod · 0.95
DidChangeWatchedFilesMethod · 0.95

Calls 6

flushChangesMethod · 0.95
UpdateSnapshotMethod · 0.95
StopMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected