Skip to content

Commit

Permalink
fix issue #2570 (#2819)
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Aug 2, 2023
1 parent f3437dc commit 0f53660
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 595 deletions.
13 changes: 7 additions & 6 deletions os/gmlock/gmlock_locker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
package gmlock

import (
"sync"

"github.com/gogf/gf/v2/container/gmap"
"github.com/gogf/gf/v2/os/gmutex"
)

// Locker is a memory based locker.
Expand Down Expand Up @@ -42,7 +43,7 @@ func (l *Locker) TryLock(key string) bool {
// Unlock unlocks the writing lock of the `key`.
func (l *Locker) Unlock(key string) {
if v := l.m.Get(key); v != nil {
v.(*gmutex.Mutex).Unlock()
v.(*sync.RWMutex).Unlock()
}
}

Expand All @@ -62,7 +63,7 @@ func (l *Locker) TryRLock(key string) bool {
// RUnlock unlocks the reading lock of the `key`.
func (l *Locker) RUnlock(key string) {
if v := l.m.Get(key); v != nil {
v.(*gmutex.Mutex).RUnlock()
v.(*sync.RWMutex).RUnlock()
}
}

Expand Down Expand Up @@ -126,8 +127,8 @@ func (l *Locker) Clear() {

// getOrNewMutex returns the mutex of given `key` if it exists,
// or else creates and returns a new one.
func (l *Locker) getOrNewMutex(key string) *gmutex.Mutex {
func (l *Locker) getOrNewMutex(key string) *sync.RWMutex {
return l.m.GetOrSetFuncLock(key, func() interface{} {
return gmutex.New()
}).(*gmutex.Mutex)
return &sync.RWMutex{}
}).(*sync.RWMutex)
}
224 changes: 0 additions & 224 deletions os/gmutex/gmutex.go

This file was deleted.

85 changes: 0 additions & 85 deletions os/gmutex/gmutex_z_bench_test.go

This file was deleted.

0 comments on commit 0f53660

Please sign in to comment.