Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type (
routineGroup *routineGroup
quit chan struct{}
ready chan struct{}
newTaskAdded chan struct{}
worker core.Worker
stopOnce sync.Once
stopFlag int32
Expand All @@ -43,6 +44,7 @@ func NewQueue(opts ...Option) (*Queue, error) {
routineGroup: newRoutineGroup(),
quit: make(chan struct{}),
ready: make(chan struct{}, 1),
newTaskAdded: make(chan struct{}),
workerCount: o.workerCount,
logger: o.logger,
worker: o.worker,
Expand Down Expand Up @@ -147,6 +149,7 @@ func (q *Queue) queue(m *job.Message) error {
}

q.metric.IncSubmittedTask()
q.newTaskAdded <- struct{}{}

return nil
}
Expand Down Expand Up @@ -320,8 +323,8 @@ func (q *Queue) start() {
close(tasks)
return
}
case <-time.After(time.Second):
// sleep 1 second to fetch new task
case <-q.newTaskAdded:
// New task added
}
}
}
Expand Down
Loading