diff --git a/context.go b/context.go index c2a81d0..83d8419 100644 --- a/context.go +++ b/context.go @@ -191,11 +191,11 @@ func NewContext(db * badger.DB, log Logger, extra_nodes map[string]NodeLoadFunc, if err != nil { panic(err) } - /*err := ctx.RegisterNodeType("simple_thread", LoadSimpleThread) + err = ctx.RegisterNodeType("simple_thread", LoadSimpleThread) if err != nil { panic(err) } - err := ctx.RegisterNodeType("gql_thread", LoadGQLThread) + /*err := ctx.RegisterNodeType("gql_thread", LoadGQLThread) if err != nil { panic(err) }*/ diff --git a/lockable.go b/lockable.go index 8697459..e4a35c5 100644 --- a/lockable.go +++ b/lockable.go @@ -7,7 +7,7 @@ import ( // A Lockable represents a Node that can be locked and hold other Nodes locks type Lockable interface { - // All Lockable's are nodes + // All Lockables are nodes Node //// State Modification Function // Record that lockable was returned to it's owner and is no longer held by this Node @@ -214,6 +214,10 @@ func (lockable * SimpleLockable) CanUnlock(new_owner Lockable) error { // lockable must already be locked for read func (lockable * SimpleLockable) Signal(ctx *Context, signal GraphSignal, nodes NodeMap) error { + err := lockable.GraphNode.Signal(ctx, signal, nodes) + if err != nil { + return err + } if signal.Direction() == Up { // Child->Parent, lockable updates dependency lockables owner_sent := false @@ -253,8 +257,7 @@ func (lockable * SimpleLockable) Signal(ctx *Context, signal GraphSignal, nodes } else { panic(fmt.Sprintf("Invalid signal direction: %d", signal.Direction())) } - // Run the base update function, and return - return lockable.GraphNode.Signal(ctx, signal, nodes) + return nil } // Requires lockable and requirement's states to be locked for write diff --git a/thread.go b/thread.go index a68ed66..137915c 100644 --- a/thread.go +++ b/thread.go @@ -267,6 +267,10 @@ type SimpleThread struct { timeout_action string } +func (thread * SimpleThread) Type() NodeType { + return NodeType("simple_thread") +} + func (thread * SimpleThread) Serialize() ([]byte, error) { thread_json := NewSimpleThreadJSON(thread) return json.MarshalIndent(&thread_json, "", " ") diff --git a/thread_test.go b/thread_test.go index 54613b8..ad87732 100644 --- a/thread_test.go +++ b/thread_test.go @@ -4,7 +4,6 @@ import ( "testing" "time" "fmt" - "encoding/json" ) func TestNewThread(t * testing.T) { @@ -87,7 +86,7 @@ func TestThreadDBLoad(t * testing.T) { fatalErr(t, err) err = UseStates(ctx, []Node{t1}, func(nodes NodeMap) error { - ser, err := json.MarshalIndent(nodes[t1.ID()], "", " ") + ser, err := t1.Serialize() fmt.Printf("\n%s\n\n", ser) return err }) @@ -96,7 +95,7 @@ func TestThreadDBLoad(t * testing.T) { fatalErr(t, err) err = UseStates(ctx, []Node{t1_loaded}, func(nodes NodeMap) error { - ser, err := json.MarshalIndent(nodes[t1_loaded.ID()], "", " ") + ser, err := t1_loaded.Serialize() fmt.Printf("\n%s\n\n", ser) return err })