Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue #2570 #2819

Merged
merged 4 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.