timerpool

package
v0.0.0-...-1679dbc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TimerPool

type TimerPool struct {
	// contains filtered or unexported fields
}

TimerPool is a wrapper of sync.Pool which caches *time.Timer for reuse.

var GlobalTimerPool TimerPool

GlobalTimerPool is a global pool for reusing *time.Timer.

func (*TimerPool) Get

func (tp *TimerPool) Get(d time.Duration) *time.Timer

Get returns a timer with a given duration.

func (*TimerPool) Put

func (tp *TimerPool) Put(timer *time.Timer)

Put tries to call timer.Stop() before putting it back into pool, if the timer.Stop() returns false (it has either already expired or been stopped), have a shot at draining the channel with residual time if there is one.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL