diff --git a/event.go b/event.go index b7fc703..75ce4ee 100644 --- a/event.go +++ b/event.go @@ -18,11 +18,9 @@ func (event * BaseEvent) update(signal GraphSignal) { SendUpdate(event.parent, new_signal) } + source_id := signal.Last() + for _, resource := range(event.RequiredResources()) { - source_id := "" - if signal.Source() != nil { - source_id = signal.Source().ID() - } if source_id != resource.ID() { SendUpdate(resource, new_signal) } diff --git a/manager.go b/manager.go index 7c383c7..43c9225 100644 --- a/manager.go +++ b/manager.go @@ -37,7 +37,7 @@ func NewEventManager(root_event Event, dag_nodes []Resource) * EventManager { return manager; } -// Connect to all resources(in a thread to handle reconnections), and start the first event +// Init to all resources(in a thread to handle reconnections), and start the first event func (manager * EventManager) Run() error { log.Logf("manager", "MANAGER_START") @@ -105,7 +105,7 @@ func (manager * EventManager) AddResource(resource Resource) error { } manager.dag_nodes[resource.ID()] = resource abort := make(chan error, 1) - abort_used := resource.Connect(abort) + abort_used := resource.Init(abort) if abort_used == true { manager.aborts = append(manager.aborts, abort) } diff --git a/resource.go b/resource.go index 0d7f9a1..1e33608 100644 --- a/resource.go +++ b/resource.go @@ -47,9 +47,9 @@ type Resource interface { LockState() UnlockState() + Init(abort chan error) bool lock(node GraphNode) error unlock(node GraphNode) error - Connect(abort chan error) bool } func AddParent(resource Resource, parent Resource) error { @@ -200,7 +200,7 @@ func (resource * BaseResource) UnlockState() { resource.state_lock.Unlock() } -func (resource * BaseResource) Connect(abort chan error) bool { +func (resource * BaseResource) Init(abort chan error) bool { return false } diff --git a/vex.go b/vex.go index f8195dc..f6a8ed7 100644 --- a/vex.go +++ b/vex.go @@ -96,8 +96,8 @@ func (arena * VirtualArena) update(signal GraphSignal) { arena.BaseResource.update(signal) } -func (arena * VirtualArena) Connect(abort chan error) bool { - log.Logf("vex", "Connecting %s", arena.Name()) +func (arena * VirtualArena) Init(abort chan error) bool { + log.Logf("vex", "Initializing %s", arena.Name()) go func(arena * VirtualArena, abort chan error) { update_str := fmt.Sprintf("VIRTUAL_ARENA connected: %s", arena.Name()) signal := NewSignal(arena, "resource_connected") @@ -130,6 +130,9 @@ func NewVexEvent(name string, description string) * VexEvent { event.actions["wait"] = EventWait(event) event.actions["start"] = func() (string, error) { log.Logf("vex", "STARTING_VEX_TOURNAMENT %s", event.Name()) + go func() { + + }() return "wait", nil }