mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: resource and slot cancel and broadcast improvements (#696)
* fn: resource and slot cancel and broadcast improvements *) Context argument does not wake up the waiters correctly upon cancellation/timeout. *) Avoid unnecessary broadcasts in slot and resource. * fn: limit scope of context in resource/slot calls in agent
This commit is contained in:
@@ -16,13 +16,13 @@ func (a *agent) asyncDequeue() {
|
||||
defer cancel()
|
||||
|
||||
for {
|
||||
ch, cancelWait := a.resources.WaitAsyncResource()
|
||||
ctxResource, cancelResource := context.WithCancel(context.Background())
|
||||
select {
|
||||
case <-a.shutdown:
|
||||
cancelWait()
|
||||
cancelResource()
|
||||
return
|
||||
case <-ch:
|
||||
cancelWait()
|
||||
case <-a.resources.WaitAsyncResource(ctxResource):
|
||||
cancelResource()
|
||||
// TODO we _could_ return a token here to reserve the ram so that there's
|
||||
// not a race between here and Submit but we're single threaded
|
||||
// dequeueing and retries handled gracefully inside of Submit if we run
|
||||
|
||||
Reference in New Issue
Block a user