fixup! fixup! fixup! Weekend fun with further optimisations.

This commit is contained in:
2025-09-14 18:28:32 +01:00
parent 9af8939f72
commit f411273fa2
10 changed files with 261 additions and 62 deletions
+22
View File
@@ -449,3 +449,25 @@ func GetGlobalMemoryMonitor() *MemoryMonitor {
})
return globalMemoryMonitor
}
// ResetGlobalMemoryMonitor resets the global memory monitor for testing
// This should only be used in tests to prevent state pollution between tests
func ResetGlobalMemoryMonitor() {
globalMonitoringMutex.Lock()
defer globalMonitoringMutex.Unlock()
if globalMemoryMonitor != nil {
// Stop monitoring if it's active
if globalMonitoringStarted {
registry := GetGlobalTaskRegistry()
if task, exists := registry.GetTask("memory-monitor"); exists {
task.Stop()
}
}
globalMemoryMonitor = nil
}
// Reset the singleton state
globalMemoryMonitorOnce = sync.Once{}
globalMonitoringStarted = false
}