From 12e0b2d6f709a966cf8ef20b42d70bbdfb5ddae8 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Wed, 25 Jan 2017 09:10:30 -0500 Subject: [PATCH] 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. --- pgraph/actions.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pgraph/actions.go b/pgraph/actions.go index ea19222b..3c437b4d 100644 --- a/pgraph/actions.go +++ b/pgraph/actions.go @@ -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. func (g *Graph) BackPoke(v *Vertex) { + var wg sync.WaitGroup // these are all the vertices pointing TO v, eg: ??? -> v for _, n := range g.IncomingGraphVertices(v) { x, y, s := v.GetTimestamp(), n.GetTimestamp(), n.Res.GetState() @@ -108,13 +109,20 @@ func (g *Graph) BackPoke(v *Vertex) { if g.Flags.Debug { 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 { if g.Flags.Debug { 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.