windy1 / zeroconf-rs

zeroconf is a cross-platform library that wraps underlying ZeroConf/mDNS implementations such as Bonjour or Avahi, providing an easy and idiomatic way to both register and browse services.
MIT License
77 stars 25 forks source link

Respect poll timeout on linux #25

Closed ERobsham closed 1 year ago

ERobsham commented 1 year ago

Updates 'linux/event_loop.rs' so we pass through the timeout to self.poll.iterate(..) rather than using a hardcoded 'zero timeout'. Also adds some test cases to loosely ensure that using a 'zero timeout' in a loop does result in a CPU hogging tight loop, and using a 'long poll' does result in as few iterations as possible (Im seeing ~1.8-2mil iterations/sec with 'zero timeout', and about 8 iterations/sec with a 1 sec timeout on my ubuntu VM).