Live video on the AT Protocol
at next 24 lines 463 B view raw
1package thumbnail 2 3import "sync" 4 5var thumbnailLocks = struct { 6 sync.Mutex 7 locks map[string]*sync.Mutex 8}{ 9 locks: make(map[string]*sync.Mutex), 10} 11 12// GetThumbnailLock returns a mutex for the given user 13func GetThumbnailLock(handle string) *sync.Mutex { 14 thumbnailLocks.Lock() 15 defer thumbnailLocks.Unlock() 16 17 if lock, exists := thumbnailLocks.locks[handle]; exists { 18 return lock 19 } 20 21 lock := &sync.Mutex{} 22 thumbnailLocks.locks[handle] = lock 23 return lock 24}