This commit is contained in:
aozhiwei 2024-04-26 13:24:30 +08:00
parent d10752d318
commit 9c2949041a

24
app.go
View File

@ -43,6 +43,7 @@ type App interface {
type UserApp interface {
GetPkgName() string
HasTask() bool
Init()
Update()
UnInit()
@ -262,10 +263,12 @@ func (this *app) goLoopTimer() {
}
func (this *app) schedule() {
this.chGoLoopWait <- GetTimer().GetIdleTime()
this.loopCond.L.Lock()
this.loopCond.Wait()
this.loopCond.L.Unlock()
if !this.hasTask() {
this.chGoLoopWait <- GetTimer().GetIdleTime()
this.loopCond.L.Lock()
this.loopCond.Wait()
this.loopCond.L.Unlock()
}
}
func (this *app) NotifyLoopCond() {
@ -425,6 +428,19 @@ func (this *app) clearEmptyPendingAsyncTask(key string) {
}
}
func (this *app) hasTask() bool {
hasTask := false
{
this.imMsgMutex.Lock()
hasTask = this.imTopNode != nil || this.imWorkNode != nil
this.imMsgMutex.Unlock()
}
if !hasTask {
hasTask = this.userApp.HasTask()
}
return hasTask
}
func parseArgs() (int, int) {
args := os.Args[1:]
if len(args) <= 0 {