func (ctx *Ctx) init() { ctx.Object = basic.NewObject(ObjId_RootId, "root", basic.Options{ MaxDone: 1024, QueueBacklog: 1024, }, nil) ctx.Object.Waitor = utils.NewWaitor() ctx.UserData = ctx }
func (tm *TimerMgr) Start() { logger.Trace("Timer Start") defer logger.Trace("Timer Start [ok]") tm.Object = basic.NewObject(core.ObjId_TimerId, "timer", Config.Options, tm) tm.UserData = tm core.LaunchChild(TimerModule.Object) }
func (e *Executor) Start() { logger.Trace("Executor Start") defer logger.Trace("Executor Start [ok]") e.Object = basic.NewObject(core.ObjId_ExecutorId, "executor", Config.Options, nil) e.c.NumberOfReplicas = WorkerVirtualNum e.UserData = e e.AddWorker(Config.Worker.WorkerCnt) core.LaunchChild(TaskExecutor.Object) }
func (e *Executor) AddWorker(workerCnt int) { for i := 0; i < workerCnt; i++ { w := &Worker{ Object: basic.NewObject(WorkerIdGenerator, fmt.Sprintf("worker_%d", WorkerIdGenerator), Config.Worker.Options, nil), } WorkerIdGenerator++ w.UserData = w e.LaunchChild(w.Object) e.c.Add(w.Name) e.workers[w.Name] = w } }
func (this *ModuleMgr) Start() *utils.Waitor { logger.Trace("Startup PreloadModules") for e := this.preloadModule.Front(); e != nil; e = e.Next() { if me, ok := e.Value.(*PreloadModuleEntity); ok { me.module.Start() } } logger.Trace("Startup PreloadModules [ok]") this.Object = basic.NewObject(core.ObjId_CoreId, "core", Config.Options, this) this.UserData = this core.LaunchChild(this.Object) this.state = ModuleStateInit //给模块预留调度的空间,防止主线程直接跑过去 select { case <-time.After(time.Second): } return this.Object.Waitor }