move sleep into the select

as it is it simply slows down the writer if there are many messages
This commit is contained in:
vyzo 2020-08-15 21:20:02 +03:00
parent 9a23ede4fd
commit 7f27c80a6a

View File

@ -30,11 +30,10 @@ func (p *Processor) subMpool(ctx context.Context) {
loop:
for {
time.Sleep(10 * time.Millisecond)
select {
case update := <-sub:
updates = append(updates, update)
default:
case <-time.After(10 * time.Millisecond):
break loop
}
}