chore: tune clock and mutex

This commit is contained in:
andig 2023-12-06 22:15:08 +01:00
parent 58e2421a5b
commit 3c78c6ac38
2 changed files with 3 additions and 3 deletions

View file

@ -210,7 +210,7 @@ func (lp *Loadpoint) SetPlanEnergy(finishAt time.Time, energy float64) error {
lp.Lock()
defer lp.Unlock()
if !finishAt.IsZero() && finishAt.Before(time.Now()) {
if !finishAt.IsZero() && finishAt.Before(lp.clock.Now()) {
return errors.New("timestamp is in the past")
}

View file

@ -49,8 +49,8 @@ func (lp *Loadpoint) resetMeasuredPhases() {
// getMeasuredPhases provides synchronized access to measuredPhases
func (lp *Loadpoint) getMeasuredPhases() int {
lp.Lock()
defer lp.Unlock()
lp.RLock()
defer lp.RUnlock()
return lp.measuredPhases
}