From 92473d15d6ea2945919e615f78b27f6c552ea6cd Mon Sep 17 00:00:00 2001 From: ErickSkrauch Date: Sun, 5 Jan 2020 23:45:11 +0300 Subject: [PATCH] Replace simple Mutex with RWMutex for in memory textures storage --- mojangtextures/in_memory_textures_storage.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mojangtextures/in_memory_textures_storage.go b/mojangtextures/in_memory_textures_storage.go index 37671df..e5b72b2 100644 --- a/mojangtextures/in_memory_textures_storage.go +++ b/mojangtextures/in_memory_textures_storage.go @@ -20,7 +20,7 @@ type InMemoryTexturesStorage struct { GCPeriod time.Duration Duration time.Duration - lock sync.Mutex + lock sync.RWMutex data map[string]*inMemoryItem working *abool.AtomicBool } @@ -60,8 +60,8 @@ func (s *InMemoryTexturesStorage) Stop() { } func (s *InMemoryTexturesStorage) GetTextures(uuid string) (*mojang.SignedTexturesResponse, error) { - s.lock.Lock() - defer s.lock.Unlock() + s.lock.RLock() + defer s.lock.RUnlock() item, exists := s.data[uuid] validRange := s.getMinimalNotExpiredTimestamp()