mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Merge pull request #31445 from pmorie/goroutinemap-godoc
Automatic merge from submit-queue Improve godoc for goroutinemap Improves the godoc of goroutinemap; found while preparing to use this type in another PR. @saad-ali
This commit is contained in:
commit
75fba4c953
@ -43,7 +43,10 @@ const (
|
|||||||
maxDurationBeforeRetry = 2 * time.Minute
|
maxDurationBeforeRetry = 2 * time.Minute
|
||||||
)
|
)
|
||||||
|
|
||||||
// GoRoutineMap defines the supported set of operations.
|
// GoRoutineMap defines a type that can run named goroutines and track their
|
||||||
|
// state. It prevents the creation of multiple goroutines with the same name
|
||||||
|
// and may prevent recreation of a goroutine until after the a backoff time
|
||||||
|
// has elapsed after the last goroutine with that name finished.
|
||||||
type GoRoutineMap interface {
|
type GoRoutineMap interface {
|
||||||
// Run adds operation name to the list of running operations and spawns a
|
// Run adds operation name to the list of running operations and spawns a
|
||||||
// new go routine to execute the operation.
|
// new go routine to execute the operation.
|
||||||
@ -59,8 +62,8 @@ type GoRoutineMap interface {
|
|||||||
// and evaluate results after that.
|
// and evaluate results after that.
|
||||||
Wait()
|
Wait()
|
||||||
|
|
||||||
// IsOperationPending returns true if the operation is pending, otherwise
|
// IsOperationPending returns true if the operation is pending (currently
|
||||||
// returns false
|
// running), otherwise returns false.
|
||||||
IsOperationPending(operationName string) bool
|
IsOperationPending(operationName string) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,6 +85,7 @@ type goRoutineMap struct {
|
|||||||
lock sync.RWMutex
|
lock sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// operation holds the state of a single goroutine.
|
||||||
type operation struct {
|
type operation struct {
|
||||||
operationPending bool
|
operationPending bool
|
||||||
expBackoff exponentialbackoff.ExponentialBackoff
|
expBackoff exponentialbackoff.ExponentialBackoff
|
||||||
@ -122,6 +126,8 @@ func (grm *goRoutineMap) Run(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// operationComplete handles the completion of a goroutine run in the
|
||||||
|
// goRoutineMap.
|
||||||
func (grm *goRoutineMap) operationComplete(
|
func (grm *goRoutineMap) operationComplete(
|
||||||
operationName string, err *error) {
|
operationName string, err *error) {
|
||||||
// Defer operations are executed in Last-In is First-Out order. In this case
|
// Defer operations are executed in Last-In is First-Out order. In this case
|
||||||
|
Loading…
Reference in New Issue
Block a user