zllangct / ecs

A Go-implementation of the ECS (Entity-Component-System), focus on the development of game server.
BSD 3-Clause "New" or "Revised" License
132 stars 10 forks source link

AsyncWorld.Wait deadlock #19

Closed bazzisl closed 1 year ago

bazzisl commented 1 year ago
func (w *AsyncWorld) Wait(fn func(g SyncWrapper) error) {
    w.lock.Lock()
    defer w.lock.Unlock()
    wait := make(chan struct{})
    w.syncQueue = append(w.syncQueue, syncTask{
        wait: wait,
        fn:   fn,
    })
    <-wait
}
func (w *AsyncWorld) Wait(fn func(g SyncWrapper) error) {
    w.lock.Lock()
    wait := make(chan struct{})
    w.syncQueue = append(w.syncQueue, syncTask{
        wait: wait,
        fn:   fn,
    })
    w.lock.Unlock()
    <-wait
}
zllangct commented 1 year ago

PR is appreciated~