Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
463 B · 24 lines
Go
12345678910111213141516171819202122232425package thumbnail
import "sync"
var thumbnailLocks = struct { sync.Mutex locks map[string]*sync.Mutex}{ locks: make(map[string]*sync.Mutex),}
// GetThumbnailLock returns a mutex for the given userfunc GetThumbnailLock(handle string) *sync.Mutex { thumbnailLocks.Lock() defer thumbnailLocks.Unlock()
if lock, exists := thumbnailLocks.locks[handle]; exists { return lock }
lock := &sync.Mutex{} thumbnailLocks.locks[handle] = lock return lock}