Skip to content

Commit

Permalink
refactor: Removing exposed mutex interface
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Nov 13, 2022
1 parent 3e4f6e1 commit ebd9ac9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/tcpool/tcpool.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type Pool struct {
done chan struct{}
backends []string
current uint64
sync.RWMutex
mutex sync.Mutex
}

func New() *Pool {
Expand All @@ -27,17 +27,17 @@ func (bp *Pool) Done() <-chan struct{} {
}

func (bp *Pool) Add(backend string) *Pool {
bp.Lock()
defer bp.Unlock()
bp.mutex.Lock()
defer bp.mutex.Unlock()

bp.backends = append(bp.backends, backend)

return bp
}

func (bp *Pool) Remove(toRemove string) *Pool {
bp.Lock()
defer bp.Unlock()
bp.mutex.Lock()
defer bp.mutex.Unlock()

backends := bp.backends[:0]
for _, backend := range bp.backends {
Expand All @@ -54,8 +54,8 @@ func (bp *Pool) Remove(toRemove string) *Pool {
}

func (bp *Pool) next() string {
bp.Lock()
defer bp.Unlock()
bp.mutex.Lock()
defer bp.mutex.Unlock()

backendsLen := uint64(len(bp.backends))
if backendsLen == 0 {
Expand Down

0 comments on commit ebd9ac9

Please sign in to comment.