summaryrefslogtreecommitdiffhomepage
path: root/device/pools.go
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2022-03-16 16:40:24 -0700
committerJosh Bleecher Snyder <josh@tailscale.com>2022-03-16 16:40:24 -0700
commit46826fc4e5dcfb472f7ae0c13d2ca65110441f0b (patch)
treead3f1463e0e6a44a7245542da5f6c734c0dfb968 /device/pools.go
parent42c9af45e12dbb2de4d3c273bfc7deeda984f827 (diff)
all: use any in place of interface{}
Enabled by using Go 1.18. A bit less verbose. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
Diffstat (limited to 'device/pools.go')
-rw-r--r--device/pools.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/device/pools.go b/device/pools.go
index f1d1fa0..f40477b 100644
--- a/device/pools.go
+++ b/device/pools.go
@@ -18,13 +18,13 @@ type WaitPool struct {
max uint32
}
-func NewWaitPool(max uint32, new func() interface{}) *WaitPool {
+func NewWaitPool(max uint32, new func() any) *WaitPool {
p := &WaitPool{pool: sync.Pool{New: new}, max: max}
p.cond = sync.Cond{L: &p.lock}
return p
}
-func (p *WaitPool) Get() interface{} {
+func (p *WaitPool) Get() any {
if p.max != 0 {
p.lock.Lock()
for atomic.LoadUint32(&p.count) >= p.max {
@@ -36,7 +36,7 @@ func (p *WaitPool) Get() interface{} {
return p.pool.Get()
}
-func (p *WaitPool) Put(x interface{}) {
+func (p *WaitPool) Put(x any) {
p.pool.Put(x)
if p.max == 0 {
return
@@ -46,13 +46,13 @@ func (p *WaitPool) Put(x interface{}) {
}
func (device *Device) PopulatePools() {
- device.pool.messageBuffers = NewWaitPool(PreallocatedBuffersPerPool, func() interface{} {
+ device.pool.messageBuffers = NewWaitPool(PreallocatedBuffersPerPool, func() any {
return new([MaxMessageSize]byte)
})
- device.pool.inboundElements = NewWaitPool(PreallocatedBuffersPerPool, func() interface{} {
+ device.pool.inboundElements = NewWaitPool(PreallocatedBuffersPerPool, func() any {
return new(QueueInboundElement)
})
- device.pool.outboundElements = NewWaitPool(PreallocatedBuffersPerPool, func() interface{} {
+ device.pool.outboundElements = NewWaitPool(PreallocatedBuffersPerPool, func() any {
return new(QueueOutboundElement)
})
}