Skip to content

Commit

Permalink
Remove use of Ticker, use After.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmallard committed Jul 26, 2020
1 parent 68e2e24 commit 8eccd03
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions unsubscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,21 @@ func (c *Connection) Unsubscribe(h Headers) error {
if err != nil {
idn = 100 // 100 milliseconds if bad parameter
}
ival := time.Duration(idn * 1000000)
//ival := time.Duration(idn * 1000000)
ival := time.Duration(time.Duration(idn) * time.Millisecond)
dmc := 0
forsel:
for {
ticker := time.NewTicker(ival)
// ticker := time.NewTicker(ival)
select {
case mi, ok := <-usesp.md:
if !ok {
break forsel
}
dmc++
c.log("sngdrnow DROP", dmc, mi.Message.Command, mi.Message.Headers)
case _ = <-ticker.C:
c.log("\nsngdrnow DROP", dmc, mi.Message.Command, mi.Message.Headers)
// case _ = <-ticker.C:
case <-time.After(ival):
c.log("sngdrnow extension BREAK")
break forsel
}
Expand Down

0 comments on commit 8eccd03

Please sign in to comment.