1
This commit is contained in:
parent
a8bed347a7
commit
764ec9224d
31
msgqueue.go
31
msgqueue.go
@ -58,5 +58,34 @@ func (this *msgQueue) UnRegisterCb(handler *MsgHandler) {
|
||||
}
|
||||
|
||||
func (this *msgQueue) FireEvent(msgId int, args q5.Args) {
|
||||
|
||||
if msgId < 0 || msgId >= len(this.msgHandlers) {
|
||||
return
|
||||
}
|
||||
node := &this.msgHandlers[msgId]
|
||||
node.lock.Lock()
|
||||
defer node.lock.Unlock()
|
||||
node.head.ForEach(
|
||||
func (data interface{}) bool {
|
||||
h := data.(*MsgHandler)
|
||||
if !h.deleted {
|
||||
h.cb(args)
|
||||
} else {
|
||||
h.entry.DelInit()
|
||||
}
|
||||
return true
|
||||
})
|
||||
node.addingLock.Lock()
|
||||
defer node.addingLock.Unlock()
|
||||
if !node.addingHead.Empty() {
|
||||
node.addingHead.ForEach(
|
||||
func (data interface{}) bool {
|
||||
h := data.(*MsgHandler)
|
||||
h.entry.DelInit()
|
||||
if !h.deleted {
|
||||
node.head.AddTail(&h.entry)
|
||||
h.cb(args)
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user