pgraph: Simplify graph exit waiting
I think the vertex resource exiting can be done in a single stage instead of the previous two stage exit.
This commit is contained in:
@@ -540,11 +540,11 @@ func (obj *Main) Run() error {
|
|||||||
reterr = multierr.Append(reterr, err) // list of errors
|
reterr = multierr.Append(reterr, err) // list of errors
|
||||||
}
|
}
|
||||||
|
|
||||||
G.Exit() // tell all the children to exit
|
|
||||||
|
|
||||||
// tell inner main loop to exit
|
// tell inner main loop to exit
|
||||||
close(exitchan)
|
close(exitchan)
|
||||||
|
|
||||||
|
G.Exit() // tell all the children to exit, and waits for them to do so
|
||||||
|
|
||||||
// cleanup etcd main loop last so it can process everything first
|
// cleanup etcd main loop last so it can process everything first
|
||||||
if err := EmbdEtcd.Destroy(); err != nil { // shutdown and cleanup etcd
|
if err := EmbdEtcd.Destroy(); err != nil { // shutdown and cleanup etcd
|
||||||
err = errwrap.Wrapf(err, "Etcd exited poorly!")
|
err = errwrap.Wrapf(err, "Etcd exited poorly!")
|
||||||
@@ -555,8 +555,6 @@ func (obj *Main) Run() error {
|
|||||||
log.Printf("Main: Graph: %v", G)
|
log.Printf("Main: Graph: %v", G)
|
||||||
}
|
}
|
||||||
|
|
||||||
G.Wait() // wait for the graph vertex worker goroutines to exit
|
|
||||||
|
|
||||||
// TODO: wait for each vertex to exit...
|
// TODO: wait for each vertex to exit...
|
||||||
log.Println("Goodbye!")
|
log.Println("Goodbye!")
|
||||||
return reterr
|
return reterr
|
||||||
|
|||||||
@@ -502,11 +502,6 @@ func (g *Graph) Start(first bool) { // start or continue
|
|||||||
wg.Wait() // wait for everyone
|
wg.Wait() // wait for everyone
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait waits for all the graph vertex workers to exit.
|
|
||||||
func (g *Graph) Wait() {
|
|
||||||
g.wg.Wait()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pause sends pause events to the graph in a topological sort order.
|
// Pause sends pause events to the graph in a topological sort order.
|
||||||
func (g *Graph) Pause() {
|
func (g *Graph) Pause() {
|
||||||
log.Printf("State: %v -> %v", g.setState(graphStatePausing), g.getState())
|
log.Printf("State: %v -> %v", g.setState(graphStatePausing), g.getState())
|
||||||
@@ -532,4 +527,5 @@ func (g *Graph) Exit() {
|
|||||||
|
|
||||||
v.SendEvent(event.EventExit, true, false)
|
v.SendEvent(event.EventExit, true, false)
|
||||||
}
|
}
|
||||||
|
g.wg.Wait() // for now, this doesn't need to be a separate Wait() method
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user