Ocean/ICCC/InitCacheTimer.go

30 lines
450 B
Go
Raw Normal View History

2015-06-17 15:44:52 +00:00
package ICCC
import (
"time"
)
2015-06-17 15:44:52 +00:00
// Setup and starts the cache timer.
func initCacheTimer() {
startCacheTimerLock.Lock()
defer startCacheTimerLock.Unlock()
if cacheTimerRunning {
return
} else {
cacheTimerRunning = true
}
// Start another thread with the timer-logic:
2015-06-17 15:44:52 +00:00
go func() {
// Endless loop:
for {
// Execute the logic:
cacheTimerLogic()
// Wait five minutes:
time.Sleep(time.Duration(5) * time.Minute)
2015-06-17 15:44:52 +00:00
}
}()
}