Skip to content

Commit

Permalink
fixed memeory bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alob-mtc committed Mar 18, 2023
1 parent 1f786f6 commit 4ec4ed1
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions eventloop.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,17 @@ func (e *eventLoop) Main(fn func()) {
}

func (e *eventLoop) awaitAll() {
select {
case <-time.After(time.Second * 1):
case <-e.signal:
for {
n := len(e.promiseQueue)
for i := n - 1; i >= 0; i-- {
p := e.promiseQueue[i]
if p.handler {
<-p.done
//TODO clean up memory (promise)
}
if currentN := int(atomic.LoadUint64(&e.size)); i == 0 && currentN > n {
// process fresh promise
e.awaitAll()
if currentN := int(atomic.LoadUint64(&e.size)); i == 0 && !(currentN > n) && !e.keepAlive {
break
}
}
}
if e.keepAlive {
e.awaitAll()
}
}

0 comments on commit 4ec4ed1

Please sign in to comment.