graph-rework-2
noah metz 2023-07-24 20:27:02 -06:00
parent bd9e0a6d6f
commit 5c3a14bdbd
1 changed files with 3 additions and 2 deletions

@ -88,14 +88,15 @@ func LinkThreads(context *StateContext, princ Node, thread_node ThreadNode, info
}
thread := thread_node.ThreadHandle()
child := info.Child.ThreadHandle()
child_node := info.Child
if thread.ID() == child.ID() {
return fmt.Errorf("Will not link %s as a child of itself", thread.ID())
}
return UpdateStates(context, princ, LockMap{
child.ID(): LockInfo{Node: child, Resources: []string{"parent"}},
thread.ID(): LockInfo{Node: thread, Resources: []string{"children"}},
child.ID(): LockInfo{Node: child_node, Resources: []string{"parent"}},
thread.ID(): LockInfo{Node: thread_node, Resources: []string{"children"}},
}, func(context *StateContext) error {
if child.Parent != nil {
return fmt.Errorf("EVENT_LINK_ERR: %s already has a parent, cannot link as child", child.ID())