Skip to content

Commit

Permalink
处理任务系统
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbbbbbbbbbbba committed Jan 17, 2022
1 parent 473c79e commit bffab99
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions server/pkg/event/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ import (
"sync"
)

var m sync.RWMutex
var eventPool *ants.PoolWithFunc
var handlers map[reflect.Type][]func(i interface{})
var wg sync.WaitGroup
var (
m sync.RWMutex
eventPool *ants.PoolWithFunc
handlers map[reflect.Type][]func(i interface{})
// wg sync.WaitGroup
)

func init() {
var err error
Expand All @@ -28,16 +30,16 @@ func dispatch(i interface{}) {
}
for _, handler := range handlerList {
handler(i)
wg.Done()
// wg.Done()
}
}

func Send(e interface{}) {
if err := eventPool.Invoke(e); err != nil {
logrus.Error(err)
} else {
wg.Add(len(getHandlerList(e)))
wg.Wait()
// wg.Add(len(getHandlerList(e)))
// wg.Wait()
}
}

Expand Down

0 comments on commit bffab99

Please sign in to comment.