mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
优化Service多协程模式
This commit is contained in:
@@ -151,28 +151,28 @@ func (s *Service) Start() {
|
|||||||
s.startStatus = true
|
s.startStatus = true
|
||||||
atomic.StoreInt32(&s.isRelease,0)
|
atomic.StoreInt32(&s.isRelease,0)
|
||||||
var waitRun sync.WaitGroup
|
var waitRun sync.WaitGroup
|
||||||
|
log.Info(s.GetName()+" service is running",)
|
||||||
|
s.self.(IService).OnStart()
|
||||||
|
|
||||||
for i:=int32(0);i< s.goroutineNum;i++{
|
for i:=int32(0);i< s.goroutineNum;i++{
|
||||||
s.wg.Add(1)
|
s.wg.Add(1)
|
||||||
waitRun.Add(1)
|
waitRun.Add(1)
|
||||||
go func(){
|
go func(){
|
||||||
log.Info(s.GetName()+" service is running",)
|
|
||||||
waitRun.Done()
|
waitRun.Done()
|
||||||
s.Run()
|
s.run()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
waitRun.Wait()
|
waitRun.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Service) Run() {
|
func (s *Service) run() {
|
||||||
defer s.wg.Done()
|
defer s.wg.Done()
|
||||||
var bStop = false
|
var bStop = false
|
||||||
|
|
||||||
concurrent := s.IConcurrent.(*concurrent.Concurrent)
|
concurrent := s.IConcurrent.(*concurrent.Concurrent)
|
||||||
concurrentCBChannel := concurrent.GetCallBackChannel()
|
concurrentCBChannel := concurrent.GetCallBackChannel()
|
||||||
|
|
||||||
s.self.(IService).OnStart()
|
|
||||||
for{
|
for{
|
||||||
var analyzer *profiler.Analyzer
|
var analyzer *profiler.Analyzer
|
||||||
select {
|
select {
|
||||||
|
|||||||
Reference in New Issue
Block a user