add NowUnixMilli NowUnixNano

This commit is contained in:
aozhiwei 2021-01-07 16:03:19 +08:00
parent 17a44afd7c
commit 32919e76e1

16
app.go
View File

@ -25,7 +25,7 @@ type App_ struct {
chGoLoopTimerExit chan int
chGoLoopWait chan int64
nowTime time.Time
nowUnix int64
nowUnixNano int64
imMsgHandlers [1024]func(int16,*q5.XParams)
maxRunDelay int64
maxScheduleTime int64
@ -33,7 +33,7 @@ type App_ struct {
func (this *App_) Init() {
this.nowTime = time.Now()
atomic.StoreInt64(&this.nowUnix, this.nowTime.Unix())
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
_Timer = &q5.Timer{}
_Timer.Init(
func (context interface{}) int64 {
@ -81,7 +81,7 @@ func (this *App_) UnInit() {
func (this *App_) Run() {
for !this.terminated {
this.nowTime = time.Now()
atomic.StoreInt64(&this.nowUnix, this.nowTime.Unix())
atomic.StoreInt64(&this.nowUnixNano, this.nowTime.UnixNano())
beginTick := q5.GetTickCount()
_Timer.Update()
@ -173,7 +173,15 @@ func (this *App_) schedule() {
}
func (this *App_) NowUnix() int64 {
return this.nowUnix
return this.nowUnixNano / int64(time.Second)
}
func (this *App_) NowUnixMilli() int64 {
return this.nowUnixNano / int64(time.Millisecond)
}
func (this *App_) NowUnixNano() int64 {
return this.nowUnixNano
}
func (this *App_) outputRuningLog() {