From 5d23646cd5cf573228c7cb6c001d569a57c32651 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Wed, 12 Jul 2023 22:31:13 -0600 Subject: [PATCH] Make restore use interface instead of struct --- thread.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/thread.go b/thread.go index 13bdbc6..d369686 100644 --- a/thread.go +++ b/thread.go @@ -246,6 +246,9 @@ type Thread interface { ChildWaits() *sync.WaitGroup } +type ParentInfo interface { + Parent() *ParentThreadInfo +} // Data required by a parent thread to restore it's children type ParentThreadInfo struct { @@ -254,6 +257,10 @@ type ParentThreadInfo struct { RestoreAction string `json:"restore_action"` } +func (info * ParentThreadInfo) Parent() *ParentThreadInfo{ + return info +} + func NewParentThreadInfo(start bool, start_action string, restore_action string) ParentThreadInfo { return ParentThreadInfo{ Start: start, @@ -551,7 +558,7 @@ var ThreadRestore = func(ctx * Context, thread Thread) { UpdateStates(ctx, []Node{thread}, func(nodes NodeMap)(error) { return UpdateMoreStates(ctx, NodeList(thread.Children()), nodes, func(nodes NodeMap) error { for _, child := range(thread.Children()) { - should_run := (thread.ChildInfo(child.ID())).(*ParentThreadInfo) + should_run := (thread.ChildInfo(child.ID())).(ParentInfo).Parent() ctx.Log.Logf("thread", "THREAD_RESTORE: %s -> %s: %+v", thread.ID(), child.ID(), should_run) if should_run.Start == true && child.State() != "finished" { ctx.Log.Logf("thread", "THREAD_RESTORED: %s -> %s", thread.ID(), child.ID())