chore: modernize
This commit is contained in:
parent
0eca536c9e
commit
77067ef783
3 changed files with 7 additions and 7 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue