Skip to content

Commit

Permalink
use RWMutex for concurrenct
Browse files Browse the repository at this point in the history
  • Loading branch information
sonroyaalmerol committed Nov 17, 2024
1 parent f22ccfb commit 18b673c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions store/concurrency.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
)

type ConcurrencyManager struct {
mu sync.Mutex
mu sync.RWMutex
count map[int]int
}

Expand All @@ -32,8 +32,8 @@ func (cm *ConcurrencyManager) Decrement(m3uIndex int) {
}

func (cm *ConcurrencyManager) GetCount(m3uIndex int) int {
cm.mu.Lock()
defer cm.mu.Unlock()
cm.mu.RLock()
defer cm.mu.RUnlock()
return cm.count[m3uIndex]
}

Expand Down

0 comments on commit 18b673c

Please sign in to comment.