summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
author Yu Liu <yudiliu@google.com> 2025-03-24 10:35:20 -0700
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2025-03-24 10:35:20 -0700
commitdbd61e8972de633832c51057b4f233d02edea7ae (patch)
tree6454486e82920b16e16773ac40c431e741865296 /android
parent232b4856cdace53f7e015baef90b5c349f213c8b (diff)
parent5e0f99715f4629040cdd0487852cf060b1f8f09d (diff)
Merge "Move SyncMap to blueprint." into main am: 5e0f99715f
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3555643 Change-Id: Ic21ac1abdfbe011f7268f4e65e4213501c719d31 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'android')
-rw-r--r--android/Android.bp1
-rw-r--r--android/raw_files.go7
-rw-r--r--android/util.go30
3 files changed, 5 insertions, 33 deletions
diff --git a/android/Android.bp b/android/Android.bp
index 71e674767..97d634fb5 100644
--- a/android/Android.bp
+++ b/android/Android.bp
@@ -12,6 +12,7 @@ bootstrap_go_package {
"blueprint-gobtools",
"blueprint-metrics",
"blueprint-pool",
+ "blueprint-syncmap",
"sbox_proto",
"soong",
"soong-android_team_proto",
diff --git a/android/raw_files.go b/android/raw_files.go
index fd371965c..ebba4d145 100644
--- a/android/raw_files.go
+++ b/android/raw_files.go
@@ -26,6 +26,7 @@ import (
"testing"
"github.com/google/blueprint"
+ "github.com/google/blueprint/syncmap"
"github.com/google/blueprint/proptools"
)
@@ -213,10 +214,10 @@ type rawFileInfo struct {
var rawFileSetKey OnceKey = NewOnceKey("raw file set")
-func getRawFileSet(config Config) *SyncMap[string, rawFileInfo] {
+func getRawFileSet(config Config) *syncmap.SyncMap[string, rawFileInfo] {
return config.Once(rawFileSetKey, func() any {
- return &SyncMap[string, rawFileInfo]{}
- }).(*SyncMap[string, rawFileInfo])
+ return &syncmap.SyncMap[string, rawFileInfo]{}
+ }).(*syncmap.SyncMap[string, rawFileInfo])
}
// ContentFromFileRuleForTests returns the content that was passed to a WriteFileRule for use
diff --git a/android/util.go b/android/util.go
index 7b305b575..4520f400e 100644
--- a/android/util.go
+++ b/android/util.go
@@ -23,7 +23,6 @@ import (
"runtime"
"sort"
"strings"
- "sync"
"github.com/google/blueprint/proptools"
)
@@ -646,35 +645,6 @@ func AddToStringSet(set map[string]bool, items []string) {
}
}
-// SyncMap is a wrapper around sync.Map that provides type safety via generics.
-type SyncMap[K comparable, V any] struct {
- sync.Map
-}
-
-// Load returns the value stored in the map for a key, or the zero value if no
-// value is present.
-// The ok result indicates whether value was found in the map.
-func (m *SyncMap[K, V]) Load(key K) (value V, ok bool) {
- v, ok := m.Map.Load(key)
- if !ok {
- return *new(V), false
- }
- return v.(V), true
-}
-
-// Store sets the value for a key.
-func (m *SyncMap[K, V]) Store(key K, value V) {
- m.Map.Store(key, value)
-}
-
-// LoadOrStore returns the existing value for the key if present.
-// Otherwise, it stores and returns the given value.
-// The loaded result is true if the value was loaded, false if stored.
-func (m *SyncMap[K, V]) LoadOrStore(key K, value V) (actual V, loaded bool) {
- v, loaded := m.Map.LoadOrStore(key, value)
- return v.(V), loaded
-}
-
// AppendIfNotZero append the given value to the slice if it is not the zero value
// for its type.
func AppendIfNotZero[T comparable](slice []T, value T) []T {