summaryrefslogtreecommitdiff
path: root/lib/containers/syncmap.go
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2023-01-26 12:23:15 -0700
committerLuke Shumaker <lukeshu@lukeshu.com>2023-01-26 12:46:07 -0700
commit716dd31f7cf52d9772fd4ed687f9cdc921443a35 (patch)
treeded6651a3b6e240f60759465af9abccd52d5984d /lib/containers/syncmap.go
parent774689062b4ac1921434a6c7a2ac78b8f29ac85a (diff)
Set up as a separate repov0.0.1
Diffstat (limited to 'lib/containers/syncmap.go')
-rw-r--r--lib/containers/syncmap.go53
1 files changed, 0 insertions, 53 deletions
diff --git a/lib/containers/syncmap.go b/lib/containers/syncmap.go
deleted file mode 100644
index 74da4b3..0000000
--- a/lib/containers/syncmap.go
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (C) 2022-2023 Luke Shumaker <lukeshu@lukeshu.com>
-//
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-package containers
-
-import (
- "sync"
-)
-
-type SyncMap[K comparable, V any] struct {
- inner sync.Map
-}
-
-func (m *SyncMap[K, V]) Delete(key K) {
- m.inner.Delete(key)
-}
-
-func (m *SyncMap[K, V]) Load(key K) (value V, ok bool) {
- _value, ok := m.inner.Load(key)
- if ok {
- //nolint:forcetypeassert // Typed wrapper around untyped lib.
- value = _value.(V)
- }
- return value, ok
-}
-
-func (m *SyncMap[K, V]) LoadAndDelete(key K) (value V, loaded bool) {
- _value, ok := m.inner.LoadAndDelete(key)
- if ok {
- //nolint:forcetypeassert // Typed wrapper around untyped lib.
- value = _value.(V)
- }
- return value, ok
-}
-
-func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) {
- _actual, loaded := m.inner.LoadOrStore(key, value)
- //nolint:forcetypeassert // Typed wrapper around untyped lib.
- actual = _actual.(V)
- return actual, loaded
-}
-
-func (m *SyncMap[K, V]) Range(f func(key K, value V) bool) {
- m.inner.Range(func(key, value any) bool {
- //nolint:forcetypeassert // Typed wrapper around untyped lib.
- return f(key.(K), value.(V))
- })
-}
-
-func (m *SyncMap[K, V]) Store(key K, value V) {
- m.inner.Store(key, value)
-}