DLV-B3: a name waiting on its floor is the builder's finding floor-silent, cleared once all three sources answer
Claude-Session: https://claude.ai/code/session_01JG73KJNrH5EgFXMKKYSrig
This commit is contained in:
@@ -135,8 +135,13 @@ type FloorWaits struct {
|
||||
keeper FloorKeeper
|
||||
// Logf says a wait that could not be kept; nil says nothing.
|
||||
Logf func(string, ...any)
|
||||
// Said is told each wait recorded (raised) and each answered (not raised): the builder's finding floor-silent.
|
||||
Said func(w FloorWait, raised bool)
|
||||
}
|
||||
|
||||
// FloorSilent is the kind of the floor finding.
|
||||
const FloorSilent = "floor-silent"
|
||||
|
||||
// Keep binds the state: the waits it holds that are not known here are taken in (a restarted builder's), every wait
|
||||
// known here is written to it, and every change from now on is.
|
||||
func (fw *FloorWaits) Keep(k FloorKeeper, held []FloorWait) {
|
||||
@@ -200,16 +205,22 @@ func (fw *FloorWaits) Wait(name, seat, holder string, f Floor, why map[string]st
|
||||
k := fw.keeper
|
||||
fw.mu.Unlock()
|
||||
fw.put(k, w)
|
||||
if fw.Said != nil {
|
||||
fw.Said(w, true)
|
||||
}
|
||||
return w
|
||||
}
|
||||
|
||||
// Answered drops name: its floor is known. It says whether the name waited, so its finding is cleared.
|
||||
func (fw *FloorWaits) Answered(name string) bool {
|
||||
fw.mu.Lock()
|
||||
_, had := fw.waits[name]
|
||||
w, had := fw.waits[name]
|
||||
delete(fw.waits, name)
|
||||
k := fw.keeper
|
||||
fw.mu.Unlock()
|
||||
if had && fw.Said != nil {
|
||||
fw.Said(w, false)
|
||||
}
|
||||
if had && k != nil {
|
||||
if err := k.Delete(FloorWaitKey(name)); err != nil && fw.Logf != nil {
|
||||
fw.Logf("the floor wait of %s is not cleared from %s: %v", name, FloorWaitsState, err)
|
||||
|
||||
Reference in New Issue
Block a user