Fixed gql threadstate

graph-rework-2
noah metz 2023-07-02 10:46:53 -06:00
parent ce0634cd61
commit 1585034777
2 changed files with 4 additions and 14 deletions

@ -448,8 +448,8 @@ var gql_actions ThreadActions = ThreadActions{
var gql_handlers ThreadHandlers = ThreadHandlers{ var gql_handlers ThreadHandlers = ThreadHandlers{
"child_added": func(ctx * GraphContext, thread Thread, signal GraphSignal) (string, error) { "child_added": func(ctx * GraphContext, thread Thread, signal GraphSignal) (string, error) {
ctx.Log.Logf("gql", "GQL_THREAD_CHILD_ADDED: %+v", signal) ctx.Log.Logf("gql", "GQL_THREAD_CHILD_ADDED: %+v", signal)
UseStates(ctx, []GraphNode{thread}, func(states NodeStateMap)(error) { UpdateStates(ctx, []GraphNode{thread}, func(nodes NodeMap)(error) {
server_state := states[thread.ID()].(*GQLThreadState) server_state := thread.State().(*GQLThreadState)
should_run, exists := server_state.child_info[signal.Source()].(*GQLThreadInfo) should_run, exists := server_state.child_info[signal.Source()].(*GQLThreadInfo)
if exists == false { if exists == false {
ctx.Log.Logf("gql", "GQL_THREAD_CHILD_ADDED: tried to start %s whis is not a child") ctx.Log.Logf("gql", "GQL_THREAD_CHILD_ADDED: tried to start %s whis is not a child")
@ -457,7 +457,7 @@ var gql_handlers ThreadHandlers = ThreadHandlers{
} }
if should_run.Start == true && should_run.Started == false { if should_run.Start == true && should_run.Started == false {
ChildGo(ctx, server_state, thread, signal.Source()) ChildGo(ctx, server_state, thread, signal.Source())
should_run.Started = false should_run.Started = true
} }
return nil return nil
}) })

@ -367,17 +367,7 @@ 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) return LockLockables(ctx, []Lockable{thread}, thread, nil, nodes)
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 { if err != nil {
return err return err