mirror of
https://github.com/kubernetes/client-go.git
synced 2025-09-04 08:35:10 +00:00
Use generics for waitFor (delaying workqueue) in client-go
With this change, we can typically avoid an extra heap allocation when calling AddAfter with a positive duration (which causes the creation of a waitFor object). This is because workqueues are typically used with string keys, and casting a string (or more generally, non-pointer types) to an `interface{}` will cause an heap escape / allocation. Ater this change, there is no longer any usage of `type t interface{}`, which was creating some confusion after the switch to generics in the workqueue package. Co-authored-by: Quan Tian <quan.tian@broadcom.com> Signed-off-by: Antonin Bas <antonin.bas@broadcom.com> Kubernetes-commit: 53ddffb55709857fec6bddbd5ca4ca1b03f7da97
This commit is contained in:
committed by
Kubernetes Publisher
parent
ba20fcad8f
commit
3c28f81659
@@ -32,7 +32,7 @@ func TestRateLimitingQueue(t *testing.T) {
|
||||
clock: fakeClock,
|
||||
heartbeat: fakeClock.NewTicker(maxWait),
|
||||
stopCh: make(chan struct{}),
|
||||
waitingForAddCh: make(chan *waitFor, 1000),
|
||||
waitingForAddCh: make(chan *waitFor[any], 1000),
|
||||
metrics: newRetryMetrics("", nil),
|
||||
}
|
||||
queue.TypedDelayingInterface = delayingQueue
|
||||
|
Reference in New Issue
Block a user