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