Skip to content

Commit

Permalink
Merge pull request #123 from icey-yu/change-wait
Browse files Browse the repository at this point in the history
feat: add push wait
  • Loading branch information
icey-yu committed Aug 14, 2024
2 parents 21b386e + 9c63d0d commit 6a2acc8
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mq/memamq/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ var (
ErrFull = errors.New("push failed: queue is full")
)

const (
pushWait = time.Second * 3
)

// AsyncQueue is the interface responsible for asynchronous processing of functions.
//type AsyncQueue interface {
// Initialize(processFunc func(), workerCount int, bufferSize int)
Expand Down Expand Up @@ -61,7 +65,7 @@ func (mq *MemoryQueue) Push(task func()) error {
if mq.isStopped.Load() {
return ErrStop
}
timer := time.NewTimer(time.Millisecond * 100)
timer := time.NewTimer(pushWait)
defer timer.Stop()
select {
case mq.taskChan <- task:
Expand Down

0 comments on commit 6a2acc8

Please sign in to comment.