From 3449ba5e5a73920da9079ebdf67832152ca358ab Mon Sep 17 00:00:00 2001 From: Stephen Searles Date: Mon, 19 Jun 2017 15:35:16 -0700 Subject: [PATCH] fixed performance issue --- client.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index e886e29..a8bebb3 100644 --- a/client.go +++ b/client.go @@ -110,7 +110,8 @@ func (c *Client) pullDeltas() []Delta { maxSize = 50 } - timeout := 10 * time.Microsecond + var timer <-chan time.Time + const timeout = 200 * time.Microsecond var ds []Delta for { @@ -119,10 +120,12 @@ func (c *Client) pullDeltas() []Delta { select { case d, ok = <-c.ch: - case <-time.After(timeout): + case <-timer: return ds } + timer = time.After(timeout) + if !ok { return ds }