减少service不必要的循环

This commit is contained in:
boyce
2019-01-30 14:55:40 +08:00
parent 34002c31a0
commit 91364a7cd8
5 changed files with 13 additions and 5 deletions

View File

@@ -139,7 +139,7 @@ func (slf *BaseService) Init(Iservice interface{}, servicetype int) error {
}
func (slf *BaseService) OnRunLoop() error {
return nil
return fmt.Errorf("None Loop")
}
func (slf *BaseService) Run(service IService, exit chan bool, pwaitGroup *sync.WaitGroup) error {
@@ -153,7 +153,9 @@ func (slf *BaseService) Run(service IService, exit chan bool, pwaitGroup *sync.W
default:
}
slf.tickTime = time.Now().UnixNano() / 1e6
service.OnRunLoop()
if service.OnRunLoop() != nil {
break
}
slf.tickTime = time.Now().UnixNano() / 1e6
}