From ce0634cd61366322279fd5991cc2f1d9be5f3a70 Mon Sep 17 00:00:00 2001 From: Noah Metz Date: Sun, 2 Jul 2023 10:39:15 -0600 Subject: [PATCH] Only lock thread during RunThread if it's not already owned by the thread --- thread.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/thread.go b/thread.go index 5759f4b..0691b8e 100644 --- a/thread.go +++ b/thread.go @@ -367,7 +367,17 @@ func RunThread(ctx * GraphContext, thread Thread) error { ctx.Log.Logf("thread", "THREAD_RUN: %s", thread.ID()) err := UpdateStates(ctx, []GraphNode{thread}, func(nodes NodeMap) (error) { - return LockLockables(ctx, []Lockable{thread}, thread, nil, nodes) + thread_state := thread.State().(ThreadState) + owner_id := NodeID("") + if thread_state.Owner() != nil { + owner_id = thread_state.Owner().ID() + } + + if owner_id != thread.ID() { + return LockLockables(ctx, []Lockable{thread}, thread, nil, nodes) + } else { + return nil + } }) if err != nil { return err