mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-10 15:20:56 +00:00
lib/events: Speed up event polling loop slightly (ref #3952)
GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3954
This commit is contained in:
parent
81418d724a
commit
8cccecceba
@ -294,18 +294,7 @@ func NewBufferedSubscription(s *Subscription, size int) BufferedSubscription {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *bufferedSubscription) pollingLoop() {
|
func (s *bufferedSubscription) pollingLoop() {
|
||||||
for {
|
for ev := range s.sub.C() {
|
||||||
ev, err := s.sub.Poll(60 * time.Second)
|
|
||||||
if err == ErrTimeout {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if err == ErrClosed {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if err != nil {
|
|
||||||
panic("unexpected error: " + err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
s.mut.Lock()
|
s.mut.Lock()
|
||||||
s.buf[s.next] = ev
|
s.buf[s.next] = ev
|
||||||
s.next = (s.next + 1) % len(s.buf)
|
s.next = (s.next + 1) % len(s.buf)
|
||||||
|
Loading…
Reference in New Issue
Block a user