Don't use time.After if there is no timeout
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
7080f5d1cf
commit
bc6ad1608c
1 changed files with 8 additions and 1 deletions
|
@ -58,10 +58,17 @@ func (p *Publisher) Publish(v interface{}) {
|
|||
p.m.RLock()
|
||||
for sub := range p.subscribers {
|
||||
// send under a select as to not block if the receiver is unavailable
|
||||
if p.timeout > 0 {
|
||||
select {
|
||||
case sub <- v:
|
||||
case <-time.After(p.timeout):
|
||||
}
|
||||
continue
|
||||
}
|
||||
select {
|
||||
case sub <- v:
|
||||
default:
|
||||
}
|
||||
}
|
||||
p.m.RUnlock()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue