pgraph, resources: Run the resource Setup in parallel

This is a reasonable thing to do at this time.
This commit is contained in:
James Shubin
2017-03-13 07:36:41 -04:00
parent e4e39d820c
commit 074da4da19
2 changed files with 15 additions and 7 deletions

View File

@@ -440,7 +440,8 @@ func (obj *BaseRes) QuiesceGroup() *sync.WaitGroup { return obj.quiesceGroup }
func (obj *BaseRes) WaitGroup() *sync.WaitGroup { return obj.waitGroup }
// Setup does some work which must happen before the Worker starts. It happens
// once per Worker startup.
// once per Worker startup. It can happen in parallel with other Setup calls, so
// add locks around any operation that's not thread-safe.
func (obj *BaseRes) Setup() {
obj.started = make(chan struct{}) // closes when started
obj.stopped = make(chan struct{}) // closes when stopped
@@ -450,7 +451,7 @@ func (obj *BaseRes) Setup() {
obj.eventsChan = make(chan *event.Event) // unbuffered chan to avoid stale events
}
// Reset from Setup.
// Reset from Setup. These can get called for different vertices in parallel.
func (obj *BaseRes) Reset() {
return
}