mirror of
https://github.com/elyby/chrly.git
synced 2024-12-23 21:50:03 +05:30
Replace simple Mutex with RWMutex for in memory textures storage
This commit is contained in:
parent
bc1427dd1f
commit
92473d15d6
@ -20,7 +20,7 @@ type InMemoryTexturesStorage struct {
|
|||||||
GCPeriod time.Duration
|
GCPeriod time.Duration
|
||||||
Duration time.Duration
|
Duration time.Duration
|
||||||
|
|
||||||
lock sync.Mutex
|
lock sync.RWMutex
|
||||||
data map[string]*inMemoryItem
|
data map[string]*inMemoryItem
|
||||||
working *abool.AtomicBool
|
working *abool.AtomicBool
|
||||||
}
|
}
|
||||||
@ -60,8 +60,8 @@ func (s *InMemoryTexturesStorage) Stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *InMemoryTexturesStorage) GetTextures(uuid string) (*mojang.SignedTexturesResponse, error) {
|
func (s *InMemoryTexturesStorage) GetTextures(uuid string) (*mojang.SignedTexturesResponse, error) {
|
||||||
s.lock.Lock()
|
s.lock.RLock()
|
||||||
defer s.lock.Unlock()
|
defer s.lock.RUnlock()
|
||||||
|
|
||||||
item, exists := s.data[uuid]
|
item, exists := s.data[uuid]
|
||||||
validRange := s.getMinimalNotExpiredTimestamp()
|
validRange := s.getMinimalNotExpiredTimestamp()
|
||||||
|
Loading…
Reference in New Issue
Block a user