1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package timer
- import (
- "context"
- "fmt"
- "ipsomc/module/bparam/bparamapi"
- "ipsomc/public"
- "sync/atomic"
- "time"
- )
- var bparamApi bparamapi.BparamApi
- var gTimerCounter int32 = 0
- func CreateTimer(ctx context.Context) {
- ticker := time.NewTicker(5 * time.Minute)
- defer ticker.Stop()
-
- sysWorkMode := public.PublicSysWorkModeGet()
-
- for {
- select {
- case <-ctx.Done():
- return
- case t := <-ticker.C:
- if sysWorkMode == 0 {
- fmt.Println("定时器触发时间:", t.Format("2006-01-02 15:16:17"))
- }
-
- newVal := atomic.AddInt32(&gTimerCounter, 1)
-
- if newVal >= 6 {
- atomic.StoreInt32(&gTimerCounter, 0)
- go bparamApi.UpdateBtsStatusByHeartMap(public.Gpub_mapHeart)
- }
- }
- }
- }
|