mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: common.WaitGroup improvements (#940)
* fn: common.WaitGroup improvements *) Split the API into AddSession/DoneSession *) Only wake up listeners when session count reaches zero. * fn: WaitGroup go-routine blast test * fn: test fix and rebase fixup
This commit is contained in:
@@ -23,7 +23,7 @@ func (a *agent) asyncDequeue() {
|
||||
for {
|
||||
select {
|
||||
case <-a.shutWg.Closer():
|
||||
a.shutWg.AddSession(-1)
|
||||
a.shutWg.DoneSession()
|
||||
return
|
||||
case <-a.resources.WaitAsyncResource(ctx):
|
||||
// TODO we _could_ return a token here to reserve the ram so that there's
|
||||
@@ -35,13 +35,13 @@ func (a *agent) asyncDequeue() {
|
||||
// we think we can get a cookie now, so go get a cookie
|
||||
select {
|
||||
case <-a.shutWg.Closer():
|
||||
a.shutWg.AddSession(-1)
|
||||
a.shutWg.DoneSession()
|
||||
return
|
||||
case model, ok := <-a.asyncChew(ctx):
|
||||
if ok {
|
||||
go func(model *models.Call) {
|
||||
a.asyncRun(ctx, model)
|
||||
a.shutWg.AddSession(-1)
|
||||
a.shutWg.DoneSession()
|
||||
}(model)
|
||||
|
||||
// WARNING: tricky. We reserve another session for next iteration of the loop
|
||||
|
||||
Reference in New Issue
Block a user