selfcompose: one pass at a time; the hand passes of the 1966 step run on a copy
TestSelfcompose/TheNodeComposesItsWantsFromTheBus failed pipelines main.266, main.459 and main.479: its issue 1966 step composed by hand beside the composer's running loop, and a loop pass woken by an entry's answer composed tool too and handed it on out, so a later quiet or wait saw n1.tool. The kind is two passes over one composer's state at once. compose and composeEarly now hold one lock (passMu) for the whole pass, so a pass asked while another runs is made after it. The lock alone does not take the order away (the loop's woken pass may still come before the test's), so the step's passes run on a copy of what the composer holds (scratch), which runs no loop; the take-back pass at its end is no longer needed and goes. The test of an ask while a pass runs also makes a pass by hand there: it does not begin until the running one ended (fails without the lock). Its read of what runs no longer blocks once eight reads are unheard (a pass reads it more than once, and the extra pass filled the channel). Issue 721 note 11 (a blocking fault for its live proof).
This commit is contained in:
@@ -309,6 +309,10 @@ type Composer struct {
|
||||
asked chan chan Pass
|
||||
// passing is set while a pass is made.
|
||||
passing atomic.Bool
|
||||
// passMu is held for the whole of a pass (compose, composeEarly): a second pass over this composer's state waits for
|
||||
// the one running to end, never runs beside it (issue 721 note 11: a pass beside the loop's handed again what the
|
||||
// other had taken back).
|
||||
passMu sync.Mutex
|
||||
// early is true while the early pass of a start runs (design 47 G §683, A-117).
|
||||
early atomic.Bool
|
||||
// assignmentsRead is set once the watch of the seat's assignments has caught up: from then the placements this composer holds
|
||||
@@ -1089,8 +1093,16 @@ func (c *Composer) takeValue(u agent.Update) {
|
||||
}
|
||||
|
||||
// compose composes the node once and answers the updates to hand: each composition whose digest differs from the one
|
||||
// handed, and a deletion for each handed one no want names any more.
|
||||
// handed, and a deletion for each handed one no want names any more. It holds passMu for the whole pass, so a pass asked
|
||||
// while another runs is made after it.
|
||||
func (c *Composer) compose(ctx context.Context) []agent.Update {
|
||||
c.passMu.Lock()
|
||||
defer c.passMu.Unlock()
|
||||
return c.composePass(ctx)
|
||||
}
|
||||
|
||||
// composePass is compose's pass, made with passMu held.
|
||||
func (c *Composer) composePass(ctx context.Context) []agent.Update {
|
||||
early := c.early.Load()
|
||||
pass := Pass{}
|
||||
defer func() {
|
||||
@@ -2645,8 +2657,11 @@ func (c *Composer) standing() bool {
|
||||
|
||||
// composeEarly is the pass of a start before the assignments, haves and resolved values are read: it composes only the modules whose
|
||||
// kept want and kept entry it holds, a kept want standing for their placement, and leaves every other module as it runs; the full
|
||||
// pass follows once the inputs are read (design 47 G §683, A-95, A-117).
|
||||
// pass follows once the inputs are read (design 47 G §683, A-95, A-117). The placement it stands in for the assignments, and
|
||||
// its taking back, are within the pass: passMu is held for all of it.
|
||||
func (c *Composer) composeEarly(ctx context.Context) []agent.Update {
|
||||
c.passMu.Lock()
|
||||
defer c.passMu.Unlock()
|
||||
node := c.env.Node
|
||||
c.mu.Lock()
|
||||
_, hadRecord := c.records[node]
|
||||
@@ -2684,5 +2699,5 @@ func (c *Composer) composeEarly(ctx context.Context) []agent.Update {
|
||||
}
|
||||
}()
|
||||
c.env.Say("the node composes the modules it kept a want and an entry of, before its other inputs are read")
|
||||
return c.compose(ctx)
|
||||
return c.composePass(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user