chore: modernize

This commit is contained in:
andig 2026-05-05 08:43:23 +02:00
parent 0eca536c9e
commit 77067ef783
3 changed files with 7 additions and 7 deletions

View file

@ -7,6 +7,7 @@ import (
"reflect"
"slices"
"sync"
"sync/atomic"
"testing"
"time"
@ -85,7 +86,7 @@ type Loadpoint struct {
lpChan chan<- *Loadpoint // update requests
log *util.Logger
rwMutex int64 // count reentrant RWMutex
rwMutex atomic.Int64 // count reentrant RWMutex
sync.RWMutex // guard status
vmu sync.RWMutex // guard vehicle

View file

@ -1,12 +1,11 @@
package core
import (
"sync/atomic"
"testing"
)
func (lp *Loadpoint) RLock() {
if testing.Testing() && atomic.AddInt64(&lp.rwMutex, 1) > 1 {
if testing.Testing() && lp.rwMutex.Add(1) > 1 {
panic("reentrant RLock")
}
lp.RWMutex.RLock()
@ -14,13 +13,13 @@ func (lp *Loadpoint) RLock() {
func (lp *Loadpoint) RUnlock() {
if testing.Testing() {
atomic.AddInt64(&lp.rwMutex, -1)
lp.rwMutex.Add(-1)
}
lp.RWMutex.RUnlock()
}
func (lp *Loadpoint) Lock() {
if testing.Testing() && atomic.AddInt64(&lp.rwMutex, 1) > 1 {
if testing.Testing() && lp.rwMutex.Add(1) > 1 {
panic("reentrant Lock")
}
lp.RWMutex.Lock()
@ -28,7 +27,7 @@ func (lp *Loadpoint) Lock() {
func (lp *Loadpoint) Unlock() {
if testing.Testing() {
atomic.AddInt64(&lp.rwMutex, -1)
lp.rwMutex.Add(-1)
}
lp.RWMutex.Unlock()
}