Put pools the given timer. There is no need to call t.Stop() before calling Put. Put will try to stop the timer before pooling. If the given timer already expired, Put will read the unreceived value if there is one.
(t *time.Timer)
| 45 | // given timer already expired, Put will read the unreceived |
| 46 | // value if there is one. |
| 47 | func (tp *timerPool) Put(t *time.Timer) { |
| 48 | if !t.Stop() { |
| 49 | select { |
| 50 | case <-t.C: |
| 51 | default: |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | tp.p.Put(t) |
| 56 | } |