Skip to content

Commit

Permalink
add task defer
Browse files Browse the repository at this point in the history
  • Loading branch information
link1st committed Sep 28, 2019
1 parent 41bef54 commit 4c45688
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions servers/task/task_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ func Timer(delay, tick time.Duration, fun TimerFunc, param interface{}, funcDefe
if fun == nil {
return
}

t := time.NewTimer(delay)
defer t.Stop()

for {
select {
case <-t.C:
Expand Down

0 comments on commit 4c45688

Please sign in to comment.