Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
wzshiming committed Nov 27, 2024
1 parent 5f40b20 commit c55737a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/utils/queue/parallelism.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ type Parallelism[T any] struct {

func NewParallelismQueue[T any](ctx context.Context, q Queue[T], startFunc func(ctx context.Context)) *Parallelism[T] {
go startFunc(ctx)
go startFunc(ctx)
go startFunc(ctx)
go startFunc(ctx)

return &Parallelism[T]{
ctx: ctx,
Expand All @@ -45,7 +48,8 @@ func (p *Parallelism[T]) GetOrWaitWithDone(done <-chan struct{}) (T, bool) {
return t, false
}

if p.Len() > 10 {
length := p.Len()
if length > 3 {
now := time.Now()
if now.Sub(p.latestStart) > time.Second {
go p.startFunc(p.ctx)
Expand Down

0 comments on commit c55737a

Please sign in to comment.