mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-18 17:21:23 +00:00
Update docs on shutdown and draining
Kubernetes-commit: 67aaa956da3e6110e8155cc08539c488fc5e1298
This commit is contained in:
parent
f84a70ae3c
commit
6116f46372
@ -212,7 +212,9 @@ type Typed[t comparable] struct {
|
||||
clock clock.WithTicker
|
||||
}
|
||||
|
||||
// Add marks item as needing processing.
|
||||
// Add marks item as needing processing. When the queue is shutdown new
|
||||
// items will silently be ignored and not queued or marked as dirty for
|
||||
// reprocessing.
|
||||
func (q *Typed[T]) Add(item T) {
|
||||
q.cond.L.Lock()
|
||||
defer q.cond.L.Unlock()
|
||||
@ -290,8 +292,9 @@ func (q *Typed[T]) Done(item T) {
|
||||
}
|
||||
}
|
||||
|
||||
// ShutDown will cause q to ignore all new items added to it and
|
||||
// immediately instruct the worker goroutines to exit.
|
||||
// ShutDown will cause q to ignore all new items added to it. Worker
|
||||
// goroutines will continue processing items in the queue until it is
|
||||
// empty and then receive the shutdown signal.
|
||||
func (q *Typed[T]) ShutDown() {
|
||||
q.cond.L.Lock()
|
||||
defer q.cond.L.Unlock()
|
||||
@ -301,15 +304,12 @@ func (q *Typed[T]) ShutDown() {
|
||||
q.cond.Broadcast()
|
||||
}
|
||||
|
||||
// ShutDownWithDrain will cause q to ignore all new items added to it. As soon
|
||||
// as the worker goroutines have "drained", i.e: finished processing and called
|
||||
// Done on all existing items in the queue; they will be instructed to exit and
|
||||
// ShutDownWithDrain will return. Hence: a strict requirement for using this is;
|
||||
// your workers must ensure that Done is called on all items in the queue once
|
||||
// the shut down has been initiated, if that is not the case: this will block
|
||||
// indefinitely. It is, however, safe to call ShutDown after having called
|
||||
// ShutDownWithDrain, as to force the queue shut down to terminate immediately
|
||||
// without waiting for the drainage.
|
||||
// ShutDownWithDrain is equivalent to ShutDown but waits until all items
|
||||
// in the queue have been processed.
|
||||
// ShutDown can be called after ShutDownWithDrain to force
|
||||
// ShutDownWithDrain to stop waiting.
|
||||
// Workers must call Done on an item after processing it, otherwise
|
||||
// ShutDownWithDrain will block indefinitely.
|
||||
func (q *Typed[T]) ShutDownWithDrain() {
|
||||
q.cond.L.Lock()
|
||||
defer q.cond.L.Unlock()
|
||||
|
Loading…
Reference in New Issue
Block a user