Skip to content

Commit

Permalink
Improve godoc for goroutinemap
Browse files Browse the repository at this point in the history
  • Loading branch information
pmorie committed Aug 25, 2016
1 parent b44b716 commit 1294267
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/util/goroutinemap/goroutinemap.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ const (
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 {
// Run adds operation name to the list of running operations and spawns a
// new go routine to execute the operation.
Expand All @@ -59,8 +62,8 @@ type GoRoutineMap interface {
// and evaluate results after that.
Wait()

// IsOperationPending returns true if the operation is pending, otherwise
// returns false
// IsOperationPending returns true if the operation is pending (currently
// running), otherwise returns false.
IsOperationPending(operationName string) bool
}

Expand All @@ -82,6 +85,7 @@ type goRoutineMap struct {
lock sync.RWMutex
}

// operation holds the state of a single goroutine.
type operation struct {
operationPending bool
expBackoff exponentialbackoff.ExponentialBackoff
Expand Down Expand Up @@ -122,6 +126,8 @@ func (grm *goRoutineMap) Run(
return nil
}

// operationComplete handles the completion of a goroutine run in the
// goRoutineMap.
func (grm *goRoutineMap) operationComplete(
operationName string, err *error) {
// Defer operations are executed in Last-In is First-Out order. In this case
Expand Down

0 comments on commit 1294267

Please sign in to comment.