pgraph: Parallelize the BackPoke facility
I can't guarantee this has a significant effect, but it's likely to add some efficiency when sending multiple BackPoke's at the same time, so that erroneous ones can be cancelled out easier.
This commit is contained in:
@@ -95,6 +95,7 @@ func (g *Graph) Poke(v *Vertex) error {
|
|||||||
|
|
||||||
// BackPoke pokes the pre-requisites that are stale and need to run before I can run.
|
// BackPoke pokes the pre-requisites that are stale and need to run before I can run.
|
||||||
func (g *Graph) BackPoke(v *Vertex) {
|
func (g *Graph) BackPoke(v *Vertex) {
|
||||||
|
var wg sync.WaitGroup
|
||||||
// these are all the vertices pointing TO v, eg: ??? -> v
|
// these are all the vertices pointing TO v, eg: ??? -> v
|
||||||
for _, n := range g.IncomingGraphVertices(v) {
|
for _, n := range g.IncomingGraphVertices(v) {
|
||||||
x, y, s := v.GetTimestamp(), n.GetTimestamp(), n.Res.GetState()
|
x, y, s := v.GetTimestamp(), n.GetTimestamp(), n.Res.GetState()
|
||||||
@@ -108,13 +109,20 @@ func (g *Graph) BackPoke(v *Vertex) {
|
|||||||
if g.Flags.Debug {
|
if g.Flags.Debug {
|
||||||
log.Printf("%s[%s]: BackPoke: %s[%s]", v.Kind(), v.GetName(), n.Kind(), n.GetName())
|
log.Printf("%s[%s]: BackPoke: %s[%s]", v.Kind(), v.GetName(), n.Kind(), n.GetName())
|
||||||
}
|
}
|
||||||
n.SendEvent(event.EventBackPoke, nil)
|
wg.Add(1)
|
||||||
|
go func(nn *Vertex) error {
|
||||||
|
defer wg.Done()
|
||||||
|
return nn.SendEvent(event.EventBackPoke, nil)
|
||||||
|
}(n)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if g.Flags.Debug {
|
if g.Flags.Debug {
|
||||||
log.Printf("%s[%s]: BackPoke: %s[%s]: Skipped!", v.Kind(), v.GetName(), n.Kind(), n.GetName())
|
log.Printf("%s[%s]: BackPoke: %s[%s]: Skipped!", v.Kind(), v.GetName(), n.Kind(), n.GetName())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO: do something with return values?
|
||||||
|
wg.Wait() // wait for all the pokes to complete
|
||||||
}
|
}
|
||||||
|
|
||||||
// RefreshPending determines if any previous nodes have a refresh pending here.
|
// RefreshPending determines if any previous nodes have a refresh pending here.
|
||||||
|
|||||||
Reference in New Issue
Block a user