定时器对象 不使用的时候释放掉
This commit is contained in:
parent
88423a2301
commit
564204c777
@ -55,6 +55,7 @@ func (c *ConnServiceImpl) WsConnect(wsUrl string) error {
|
||||
c.ws = ws
|
||||
|
||||
ticker := time.NewTicker(2 * time.Second)
|
||||
defer ticker.Stop()
|
||||
go func() {
|
||||
for {
|
||||
_ = <-ticker.C
|
||||
|
@ -46,14 +46,15 @@ type Configure struct {
|
||||
}
|
||||
|
||||
func (this *Configure) Start() (err error) {
|
||||
tc := time.NewTicker(time.Second * time.Duration(this.options.CheckInterval))
|
||||
timer := time.NewTicker(time.Second * time.Duration(this.options.CheckInterval))
|
||||
defer timer.Stop()
|
||||
go func() {
|
||||
locp:
|
||||
for {
|
||||
select {
|
||||
case <-this.closeSignal:
|
||||
break locp
|
||||
case <-tc.C:
|
||||
case <-timer.C:
|
||||
this.checkConfigure()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user