MCPcopy
hub / github.com/nats-io/nats.go / Put

Method Put

timer.go:47–56  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

45// given timer already expired, Put will read the unreceived
46// value if there is one.
47func (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}

Callers 1

TestTimerPoolFunction · 0.95

Calls 2

StopMethod · 0.65
PutMethod · 0.65

Tested by 1

TestTimerPoolFunction · 0.76