MCPcopy Index your code
hub / github.com/koding/kite / Do

Method Do

kontrol/onceevery/onceevery.go:28–44  ·  view source on GitHub ↗

Do calls the function f if and only if Do hits the given periodic interval. In other words Do can be called multiple times during the interval but it gets called only once if it hits the interval tick. So if the interval is 10 seconds, and a total of 100 calls are made during this period, f will be

(f func())

Source from the content-addressed store, hash-verified

26// 10 seconds, and a total of 100 calls are made during this period, f will
27// be called it every 10 seconds.
28func (o *OnceEvery) Do(f func()) {
29 if f == nil {
30 panic("passed function is nil")
31 }
32
33 o.mu.Lock()
34 now := time.Now()
35 ok := o.last.Add(o.Interval).Before(now)
36 if ok {
37 o.last = now
38 }
39 o.mu.Unlock()
40
41 if ok {
42 f()
43 }
44}

Callers 12

SetupKontrolClientMethod · 0.80
signalReadyMethod · 0.80
RenewWhenExpiresMethod · 0.80
RSAKeyMethod · 0.80
newRequestMethod · 0.80
AuthenticateFromTokenMethod · 0.80
verifyMethod · 0.80
doMethod · 0.80
ReadMethod · 0.80
ReadByteMethod · 0.80
HandleRegisterMethod · 0.80
TestOnceEveryFunction · 0.80

Calls 1

AddMethod · 0.65

Tested by 1

TestOnceEveryFunction · 0.64