mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
fn: cancellations in WaitAsyncResource (#694)
* fn: cancellations in WaitAsyncResource Added go context with cancel to wait async resource. Although today, the only case for cancellation is shutdown, this cleans up agent shutdown a little bit. * fn: locked broadcast to avoid missed wake-ups * fn: removed ctx arg to WaitAsyncResource and startDequeuer This is confusing and unnecessary.
This commit is contained in:
@@ -16,10 +16,13 @@ func (a *agent) asyncDequeue() {
|
||||
defer cancel()
|
||||
|
||||
for {
|
||||
ch, cancelWait := a.resources.WaitAsyncResource()
|
||||
select {
|
||||
case <-a.shutdown:
|
||||
cancelWait()
|
||||
return
|
||||
case <-a.resources.WaitAsyncResource():
|
||||
case <-ch:
|
||||
cancelWait()
|
||||
// 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