func (d *Dwimmer) watchdog(setting *term.SettingT) { if rand.Int()%(watchFrequency<<(3*watcherDepth)) == 0 { watcherDepth++ defer func() { watcherDepth-- }() parent := setting.Copy().AppendAction(term.MetaC()) oldWatcher := d.lastWatcher newWatcher := term.InitT() var Q term.T if d.lastWatcher == nil { Q = IsAllWell.T(term.MakeChannel(parent)) } else { Q = IsAllWellPred.T(term.MakeChannel(parent), term.MakeChannel(oldWatcher)) } d.lastWatcher = newWatcher dynamics.SubRun(d, Q, parent, newWatcher) } }
func SubRun(d Dwimmer, Q term.T, parent *term.SettingT, optionalChild ...*term.SettingT) term.T { var child *term.SettingT if len(optionalChild) == 1 { child = optionalChild[0] } else { child = term.InitT() } child.AppendTerm(Parent(parent)) child.AppendTerm(Q) d.Push(Q) stackCheck() A := d.Run(child) parent.AppendTerm(OpenChannel.T(term.MakeChannel(child))) if A != nil { parent.AppendTerm(A) } d.Pop() return A }
func Parent(s *term.SettingT) term.T { return ParentChannel.T(term.MakeChannel(s)) }