Un-exported event and resource fields
This commit is contained in:
parent
ca038062a7
commit
c70e4a4f32
29
event.go
29
event.go
|
|
@ -26,9 +26,9 @@ func (event * BaseEvent) update(signal GraphSignal) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Parent->Child
|
// Parent->Child
|
||||||
event.ChildrenSliceLock.Lock()
|
event.children_lock.Lock()
|
||||||
defer event.ChildrenSliceLock.Unlock()
|
defer event.children_lock.Unlock()
|
||||||
for _, child := range(event.ChildrenSlice) {
|
for _, child := range(event.children) {
|
||||||
SendUpdate(child, signal)
|
SendUpdate(child, signal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -308,9 +308,10 @@ type BaseEvent struct {
|
||||||
done_resource Resource
|
done_resource Resource
|
||||||
rr_lock sync.Mutex
|
rr_lock sync.Mutex
|
||||||
required_resources []Resource
|
required_resources []Resource
|
||||||
ChildrenSlice []Event
|
children []Event
|
||||||
ChildInfoMap map[string]EventInfo
|
children_lock sync.Mutex
|
||||||
ChildrenSliceLock sync.Mutex
|
child_info map[string]EventInfo
|
||||||
|
child_info_lock sync.Mutex
|
||||||
actions map[string]func() (string, error)
|
actions map[string]func() (string, error)
|
||||||
handlers map[string]func(GraphSignal) (string, error)
|
handlers map[string]func(GraphSignal) (string, error)
|
||||||
parent Event
|
parent Event
|
||||||
|
|
@ -349,8 +350,8 @@ func NewBaseEvent(name string, description string, required_resources []Resource
|
||||||
event := BaseEvent{
|
event := BaseEvent{
|
||||||
BaseNode: NewBaseNode(name, description, randid()),
|
BaseNode: NewBaseNode(name, description, randid()),
|
||||||
parent: nil,
|
parent: nil,
|
||||||
ChildrenSlice: []Event{},
|
children: []Event{},
|
||||||
ChildInfoMap: map[string]EventInfo{},
|
child_info: map[string]EventInfo{},
|
||||||
done_resource: done_resource,
|
done_resource: done_resource,
|
||||||
required_resources: required_resources,
|
required_resources: required_resources,
|
||||||
actions: map[string]func()(string, error){},
|
actions: map[string]func()(string, error){},
|
||||||
|
|
@ -510,11 +511,11 @@ func (event * BaseEvent) DoneResource() Resource {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (event * BaseEvent) Children() []Event {
|
func (event * BaseEvent) Children() []Event {
|
||||||
return event.ChildrenSlice
|
return event.children
|
||||||
}
|
}
|
||||||
|
|
||||||
func (event * BaseEvent) ChildInfo(idx Event) EventInfo {
|
func (event * BaseEvent) ChildInfo(idx Event) EventInfo {
|
||||||
val, ok := event.ChildInfoMap[idx.ID()]
|
val, ok := event.child_info[idx.ID()]
|
||||||
if ok == false {
|
if ok == false {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
@ -522,11 +523,11 @@ func (event * BaseEvent) ChildInfo(idx Event) EventInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (event * BaseEvent) LockChildren() {
|
func (event * BaseEvent) LockChildren() {
|
||||||
event.ChildrenSliceLock.Lock()
|
event.children_lock.Lock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (event * BaseEvent) UnlockChildren() {
|
func (event * BaseEvent) UnlockChildren() {
|
||||||
event.ChildrenSliceLock.Unlock()
|
event.children_lock.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (event * BaseEvent) LockParent() {
|
func (event * BaseEvent) LockParent() {
|
||||||
|
|
@ -542,8 +543,8 @@ func (event * BaseEvent) setParent(parent Event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (event * BaseEvent) addChild(child Event, info EventInfo) {
|
func (event * BaseEvent) addChild(child Event, info EventInfo) {
|
||||||
event.ChildrenSlice = append(event.ChildrenSlice, child)
|
event.children = append(event.children, child)
|
||||||
event.ChildInfoMap[child.ID()] = info
|
event.child_info[child.ID()] = info
|
||||||
}
|
}
|
||||||
|
|
||||||
type GQLEvent struct {
|
type GQLEvent struct {
|
||||||
|
|
|
||||||
14
resource.go
14
resource.go
|
|
@ -25,9 +25,9 @@ func (resource * BaseResource) update(signal GraphSignal) {
|
||||||
SendUpdate(resource.lock_holder, signal)
|
SendUpdate(resource.lock_holder, signal)
|
||||||
}
|
}
|
||||||
|
|
||||||
resource.ChildrenSliceLock.Lock()
|
resource.children_lock.Lock()
|
||||||
defer resource.ChildrenSliceLock.Unlock()
|
defer resource.children_lock.Unlock()
|
||||||
for _, child := range(resource.ChildrenSlice) {
|
for _, child := range(resource.children) {
|
||||||
SendUpdate(child, signal)
|
SendUpdate(child, signal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -150,8 +150,8 @@ type BaseResource struct {
|
||||||
BaseNode
|
BaseNode
|
||||||
parents []Resource
|
parents []Resource
|
||||||
parents_lock sync.Mutex
|
parents_lock sync.Mutex
|
||||||
ChildrenSlice []Resource
|
children []Resource
|
||||||
ChildrenSliceLock sync.Mutex
|
children_lock sync.Mutex
|
||||||
lock_holder GraphNode
|
lock_holder GraphNode
|
||||||
lock_holder_lock sync.Mutex
|
lock_holder_lock sync.Mutex
|
||||||
state_lock sync.Mutex
|
state_lock sync.Mutex
|
||||||
|
|
@ -189,7 +189,7 @@ func (resource * BaseResource) unlock(node GraphNode) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (resource * BaseResource) Children() []Resource {
|
func (resource * BaseResource) Children() []Resource {
|
||||||
return resource.ChildrenSlice
|
return resource.children
|
||||||
}
|
}
|
||||||
|
|
||||||
func (resource * BaseResource) Parents() []Resource {
|
func (resource * BaseResource) Parents() []Resource {
|
||||||
|
|
@ -213,7 +213,7 @@ func NewBaseResource(name string, description string, children []Resource) BaseR
|
||||||
resource := BaseResource{
|
resource := BaseResource{
|
||||||
BaseNode: NewBaseNode(name, description, randid()),
|
BaseNode: NewBaseNode(name, description, randid()),
|
||||||
parents: []Resource{},
|
parents: []Resource{},
|
||||||
ChildrenSlice: children,
|
children: children,
|
||||||
}
|
}
|
||||||
|
|
||||||
return resource
|
return resource
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue