(key string, value T)
| 43 | } |
| 44 | |
| 45 | func (sm *SyncMap[T]) SetUnless(key string, value T) bool { |
| 46 | sm.lock.Lock() |
| 47 | defer sm.lock.Unlock() |
| 48 | if _, exists := sm.m[key]; exists { |
| 49 | return false |
| 50 | } |
| 51 | sm.m[key] = value |
| 52 | return true |
| 53 | } |
| 54 | |
| 55 | func (sm *SyncMap[T]) TestAndSet(key string, newValue T, testFn func(T, bool) bool) bool { |
| 56 | sm.lock.Lock() |