MCPcopy
hub / github.com/g3n/engine / ProcessTimers

Method ProcessTimers

core/timer.go:75–93  ·  view source on GitHub ↗

ProcessTimers should be called periodically to process the timers

()

Source from the content-addressed store, hash-verified

73
74// ProcessTimers should be called periodically to process the timers
75func (tm *TimerManager) ProcessTimers() {
76
77 now := time.Now()
78 for pos, t := range tm.timers {
79 // If empty entry, ignore
80 if t.id == 0 {
81 continue
82 }
83 // Checks if entry expired
84 if now.After(t.expire) {
85 if t.period == 0 {
86 tm.timers[pos] = timeout{}
87 } else {
88 tm.timers[pos].expire = now.Add(t.period)
89 }
90 t.cb(t.arg)
91 }
92 }
93}
94
95// setTimer sets a new timer with the specified duration
96func (tm *TimerManager) setTimer(td time.Duration, periodic bool, arg interface{}, cb TimerCallback) int {

Callers

nothing calls this directly

Calls 1

AddMethod · 0.45

Tested by

no test coverage detected