X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/d97388bdbfeb6a43cb86996012a1db0ba4a8871f..e838828374ceed5ef6da260939251e86f72b6f27:/lib/dispatchcloud/scheduler/scheduler.go?ds=sidebyside diff --git a/lib/dispatchcloud/scheduler/scheduler.go b/lib/dispatchcloud/scheduler/scheduler.go index 97cacee08f..eb82c48839 100644 --- a/lib/dispatchcloud/scheduler/scheduler.go +++ b/lib/dispatchcloud/scheduler/scheduler.go @@ -34,8 +34,9 @@ type Scheduler struct { staleLockTimeout time.Duration queueUpdateInterval time.Duration - locking map[string]bool - mtx sync.Mutex + uuidOp map[string]string // operation in progress: "lock", "cancel", ... + mtx sync.Mutex + wakeup *time.Timer runOnce sync.Once stop chan struct{} @@ -53,9 +54,10 @@ func New(ctx context.Context, queue ContainerQueue, pool WorkerPool, staleLockTi pool: pool, staleLockTimeout: staleLockTimeout, queueUpdateInterval: queueUpdateInterval, + wakeup: time.NewTimer(time.Second), stop: make(chan struct{}), stopped: make(chan struct{}), - locking: map[string]bool{}, + uuidOp: map[string]string{}, } } @@ -116,6 +118,7 @@ func (sch *Scheduler) run() { return case <-queueNotify: case <-poolNotify: + case <-sch.wakeup.C: } } }