stash/vendor/github.com/gobuffalo/genny/group.go

31 lines
449 B
Go
Raw Normal View History

2019-02-09 12:30:49 +00:00
package genny
import "sync"
type Group struct {
Generators []*Generator
moot sync.RWMutex
}
func (gg *Group) Add(g *Generator) {
m := &gg.moot
m.Lock()
defer m.Unlock()
gg.Generators = append(gg.Generators, g)
}
func (gg *Group) Merge(g2 *Group) {
for _, g := range g2.Generators {
gg.Add(g)
}
}
func (gg *Group) With(r *Runner) {
m := &gg.moot
m.RLock()
defer m.RUnlock()
for _, g := range gg.Generators {
r.With(g)
}
}