-// StartMonitor starts the squeue monitoring goroutine.
-func (squeue *Squeue) StartMonitor(pollInterval time.Duration) {
- squeue.squeueCond = sync.NewCond(&sync.Mutex{})
- squeue.squeueDone = make(chan struct{})
- go squeue.SyncSqueue(pollInterval)
-}
-
-// Done stops the squeue monitoring goroutine.
-func (squeue *Squeue) Done() {
- squeue.squeueDone <- struct{}{}
- close(squeue.squeueDone)
-}
-
-// SyncSqueue periodically polls RunSqueue() at the given duration until
-// terminated by calling Done().
-func (squeue *Squeue) SyncSqueue(pollInterval time.Duration) {
- ticker := time.NewTicker(pollInterval)
- for {
- select {
- case <-squeue.squeueDone:
- return
- case <-ticker.C:
- squeue.RunSqueue()
- }
- }