NewStoppedTimer creates a new stopped Timer.
()
| 33 | |
| 34 | // NewStoppedTimer creates a new stopped Timer. |
| 35 | func NewStoppedTimer() *Timer { |
| 36 | c := make(chan time.Time, 1) |
| 37 | t := &Timer{ |
| 38 | C: c, |
| 39 | f: func(t *time.Time) { |
| 40 | // Don't block. |
| 41 | select { |
| 42 | case c <- *t: |
| 43 | default: |
| 44 | } |
| 45 | }, |
| 46 | reset: func() { |
| 47 | // Empty the channel if filled. |
| 48 | select { |
| 49 | case <-c: |
| 50 | default: |
| 51 | } |
| 52 | }, |
| 53 | } |
| 54 | return t |
| 55 | } |
| 56 | |
| 57 | // Stop prevents the Timer from firing. |
| 58 | // It returns true if the call stops the timer, |
no outgoing calls
searching dependent graphs…