Only lock thread during RunThread if it's not already owned by the thread

graph-rework-2
noah metz 2023-07-02 10:39:15 -06:00
parent 3ebb6fe223
commit ce0634cd61
1 changed files with 11 additions and 1 deletions

@ -367,7 +367,17 @@ func RunThread(ctx * GraphContext, thread Thread) error {
ctx.Log.Logf("thread", "THREAD_RUN: %s", thread.ID()) ctx.Log.Logf("thread", "THREAD_RUN: %s", thread.ID())
err := UpdateStates(ctx, []GraphNode{thread}, func(nodes NodeMap) (error) { err := UpdateStates(ctx, []GraphNode{thread}, func(nodes NodeMap) (error) {
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) return LockLockables(ctx, []Lockable{thread}, thread, nil, nodes)
} else {
return nil
}
}) })
if err != nil { if err != nil {
return err return err