Fixup state related items

* Fixup graph state readability
* Rename original SetState() to SetConvergedState() and friends...
* Add type state management for proper BackPoke() commands...
* Add better DEBUG logging

This is an important optimization that prevents running a BackPoke on a
parent which is in the process of running and will most certainly poke
the caller back in a moment. This avoids unnecessary roundtrips.
Unfortunately, there are still other algorithms required so that races
can't cause the graph to run for longer than necessary.
This commit is contained in:
James Shubin
2016-01-12 04:30:35 -05:00
parent c57946e29b
commit 4c6647d807
8 changed files with 156 additions and 68 deletions

View File

@@ -96,15 +96,18 @@ func (g *Graph) SetName(name string) {
}
func (g *Graph) GetState() graphState {
g.mutex.Lock()
defer g.mutex.Unlock()
//g.mutex.Lock()
//defer g.mutex.Unlock()
return g.state
}
func (g *Graph) SetState(state graphState) {
// set graph state and return previous state
func (g *Graph) SetState(state graphState) graphState {
g.mutex.Lock()
defer g.mutex.Unlock()
prev := g.GetState()
g.state = state
return prev
}
// store a pointer in the type to it's parent vertex