X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fcontrol%2Ftimer.go;h=c8385a6920b0458e1926eaade743ce5704276541;hb=ff8dccd02d76eebfccc0b509ce0b42a2c1760e12;hp=5d48464afd98beb0e49ca941b94c746ceca06705;hpb=f1d0eb6a82e11f14f60e3636d526299ced0173ea;p=ric-plt%2Fsubmgr.git diff --git a/pkg/control/timer.go b/pkg/control/timer.go index 5d48464..c8385a6 100644 --- a/pkg/control/timer.go +++ b/pkg/control/timer.go @@ -54,7 +54,7 @@ Timer takes four parameters: subId := 123 timerMap.StartTimer("RIC_SUB_REQ", int(subId), subReqTime, handleSubscriptionRequestTimer) timerMap.StopTimer("RIC_SUB_REQ", int(subId)) - + 2) subReqTime := 2 * time.Second strId := "1UHSUwNqxiVgUWXvC4zFaatpZFF" @@ -82,29 +82,29 @@ import ( ) type TimerKey struct { - strId string - nbrId int + strId string + nbrId int } type TimerInfo struct { - timerAddress *time.Timer + timerAddress *time.Timer timerFunctionAddress func() } type TimerMap struct { - timer map[TimerKey] TimerInfo + timer map[TimerKey]TimerInfo mutex sync.Mutex } // This method should run as a constructor func (t *TimerMap) Init() { - t.timer = make(map[TimerKey] TimerInfo) + t.timer = make(map[TimerKey]TimerInfo) } func (t *TimerMap) StartTimer(strId string, nbrId int, expireAfterTime time.Duration, timerFunction func(srtId string, nbrId int)) bool { t.mutex.Lock() defer t.mutex.Unlock() - if (timerFunction == nil) { + if timerFunction == nil { xapp.Logger.Error("StartTimer() timerFunc == nil\n") return false } @@ -120,8 +120,8 @@ func (t *TimerMap) StartTimer(strId string, nbrId int, expireAfterTime time.Dura } // Store in timerMap in-build Go "timer", timer function executor, and the function to be executed when the timer expires - t.timer[timerKey] = TimerInfo{timerAddress: time.AfterFunc(expireAfterTime, func(){t.timerFunctionExecutor(strId,nbrId)}), - timerFunctionAddress: func(){timerFunction(strId,nbrId)}} + t.timer[timerKey] = TimerInfo{timerAddress: time.AfterFunc(expireAfterTime, func() { t.timerFunctionExecutor(strId, nbrId) }), + timerFunctionAddress: func() { timerFunction(strId, nbrId) }} return true }