use a monotonous timer for the connection (#3570)

There's no point in having the timer fire multiple times for the same
timestamp. By using a monotonuos timer we avoid busy-looping in cases where the
timer fires, but we can't actually send a packet.
This commit is contained in:
Marten Seemann
2022-10-11 15:36:10 +03:00
committed by GitHub
parent 2b5d1281c1
commit ee013d9d23
5 changed files with 137 additions and 18 deletions

View File

@@ -21,6 +21,14 @@ var _ = Describe("Timer", func() {
Eventually(t.Chan()).Should(Receive())
})
It("returns the deadline", func() {
t := NewTimer()
deadline := time.Now().Add(d)
t.Reset(deadline)
Expect(t.Deadline()).To(Equal(deadline))
Eventually(t.Chan()).Should(Receive())
})
It("works multiple times with reading", func() {
t := NewTimer()
for i := 0; i < 10; i++ {