Skip to content

Commit

Permalink
[HOTFIX] Fix atomic usage (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skandalik authored Apr 3, 2022
1 parent e24d66d commit 6ecd943
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ func newClk(clk clock.Clock) *localClock {
}

// disable mutex by default
disabled := int32(1)
lClk.mutex.disabled = &disabled
lClk.mutex.Disable()
return lClk
}

Expand Down Expand Up @@ -234,7 +233,7 @@ func NoLock() {

type mutexWrap struct {
lock sync.Mutex
disabled *int32
disabled int32
}

func (mw *mutexWrap) Lock() {
Expand All @@ -253,16 +252,16 @@ func (mw *mutexWrap) Enable() {
mw.lock.Lock()
defer mw.lock.Unlock()

atomic.StoreInt32(mw.disabled, 0)
atomic.StoreInt32(&mw.disabled, 0)
}

func (mw *mutexWrap) Disable() {
mw.lock.Lock()
defer mw.lock.Unlock()

atomic.StoreInt32(mw.disabled, 1)
atomic.StoreInt32(&mw.disabled, 1)
}

func (mw *mutexWrap) isDisabled() bool {
return atomic.LoadInt32(mw.disabled) == 1
return mw.disabled == 1
}

0 comments on commit 6ecd943

Please sign in to comment.