mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
run gofumpt cleanup across code-base (#14015)
This commit is contained in:
@@ -44,14 +44,12 @@ func NewLRWMutex() *LRWMutex {
|
||||
// If the lock is already in use, the calling go routine
|
||||
// blocks until the mutex is available.
|
||||
func (lm *LRWMutex) Lock() {
|
||||
|
||||
const isWriteLock = true
|
||||
lm.lockLoop(context.Background(), lm.id, lm.source, math.MaxInt64, isWriteLock)
|
||||
}
|
||||
|
||||
// GetLock tries to get a write lock on lm before the timeout occurs.
|
||||
func (lm *LRWMutex) GetLock(ctx context.Context, id string, source string, timeout time.Duration) (locked bool) {
|
||||
|
||||
const isWriteLock = true
|
||||
return lm.lockLoop(ctx, id, source, timeout, isWriteLock)
|
||||
}
|
||||
@@ -61,14 +59,12 @@ func (lm *LRWMutex) GetLock(ctx context.Context, id string, source string, timeo
|
||||
// If one or more read lock are already in use, it will grant another lock.
|
||||
// Otherwise the calling go routine blocks until the mutex is available.
|
||||
func (lm *LRWMutex) RLock() {
|
||||
|
||||
const isWriteLock = false
|
||||
lm.lockLoop(context.Background(), lm.id, lm.source, 1<<63-1, isWriteLock)
|
||||
}
|
||||
|
||||
// GetRLock tries to get a read lock on lm before the timeout occurs.
|
||||
func (lm *LRWMutex) GetRLock(ctx context.Context, id string, source string, timeout time.Duration) (locked bool) {
|
||||
|
||||
const isWriteLock = false
|
||||
return lm.lockLoop(ctx, id, source, timeout, isWriteLock)
|
||||
}
|
||||
@@ -128,7 +124,6 @@ func (lm *LRWMutex) lockLoop(ctx context.Context, id, source string, timeout tim
|
||||
//
|
||||
// It is a run-time error if lm is not locked on entry to Unlock.
|
||||
func (lm *LRWMutex) Unlock() {
|
||||
|
||||
isWriteLock := true
|
||||
success := lm.unlock(isWriteLock)
|
||||
if !success {
|
||||
@@ -140,7 +135,6 @@ func (lm *LRWMutex) Unlock() {
|
||||
//
|
||||
// It is a run-time error if lm is not locked on entry to RUnlock.
|
||||
func (lm *LRWMutex) RUnlock() {
|
||||
|
||||
isWriteLock := false
|
||||
success := lm.unlock(isWriteLock)
|
||||
if !success {
|
||||
@@ -178,7 +172,6 @@ func (lm *LRWMutex) ForceUnlock() {
|
||||
|
||||
lm.ref = 0
|
||||
lm.isWriteLock = false
|
||||
|
||||
}
|
||||
|
||||
// DRLocker returns a sync.Locker interface that implements
|
||||
|
||||
@@ -20,18 +20,16 @@ package lsync_test
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"runtime"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"runtime"
|
||||
|
||||
. "github.com/minio/minio/internal/lsync"
|
||||
)
|
||||
|
||||
func testSimpleWriteLock(t *testing.T, duration time.Duration) (locked bool) {
|
||||
|
||||
ctx := context.Background()
|
||||
lrwm := NewLRWMutex()
|
||||
|
||||
@@ -89,7 +87,6 @@ func TestSimpleWriteLockTimedOut(t *testing.T) {
|
||||
}
|
||||
|
||||
func testDualWriteLock(t *testing.T, duration time.Duration) (locked bool) {
|
||||
|
||||
ctx := context.Background()
|
||||
lrwm := NewLRWMutex()
|
||||
|
||||
@@ -124,7 +121,6 @@ func TestDualWriteLockAcquired(t *testing.T) {
|
||||
if locked != expected {
|
||||
t.Errorf("TestDualWriteLockAcquired(): \nexpected %#v\ngot %#v", expected, locked)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestDualWriteLockTimedOut(t *testing.T) {
|
||||
@@ -134,7 +130,6 @@ func TestDualWriteLockTimedOut(t *testing.T) {
|
||||
if locked != expected {
|
||||
t.Errorf("TestDualWriteLockTimedOut(): \nexpected %#v\ngot %#v", expected, locked)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Test cases below are copied 1 to 1 from sync/rwmutex_test.go (adapted to use LRWMutex)
|
||||
|
||||
Reference in New Issue
Block a user