- Sort Score
- Result 10 results
- Languages All
Results 1 - 10 of 17 for LoadOrStore (0.52 sec)
-
src/internal/concurrent/hashtriemap_test.go
for _, s := range testData { expectMissing(t, s, 0)(m.Load(s)) } }) t.Run("LoadOrStore", func(t *testing.T) { m := newMap() for i, s := range testData { expectMissing(t, s, 0)(m.Load(s)) expectStored(t, s, i)(m.LoadOrStore(s, i)) expectPresent(t, s, i)(m.Load(s)) expectLoaded(t, s, i)(m.LoadOrStore(s, 0)) } for i, s := range testData { expectPresent(t, s, i)(m.Load(s))
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed May 22 16:01:55 UTC 2024 - 9.3K bytes - Viewed (0) -
src/expvar/expvar.go
} func (v *Map) Set(key string, av Var) { // Before we store the value, check to see whether the key is new. Try a Load // before LoadOrStore: LoadOrStore causes the key interface to escape even on // the Load path. if _, ok := v.m.Load(key); !ok { if _, dup := v.m.LoadOrStore(key, av); !dup { v.addKey(key) return } } v.m.Store(key, av) }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Fri Apr 26 21:32:11 UTC 2024 - 9.1K bytes - Viewed (0) -
src/internal/concurrent/hashtriemap_bench_test.go
benchmarkHashTrieMapLoad(b, testDataLarge[:]) } func benchmarkHashTrieMapLoad(b *testing.B, data []string) { b.ReportAllocs() m := NewHashTrieMap[string, int]() for i := range data { m.LoadOrStore(data[i], i) } b.ResetTimer() b.RunParallel(func(pb *testing.PB) { i := 0 for pb.Next() { _, _ = m.Load(data[i]) i++ if i >= len(data) { i = 0 } } }) }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu Apr 18 21:20:09 UTC 2024 - 1.3K bytes - Viewed (0) -
src/unique/handle.go
toInsertWeak = weak.Make(toInsert) } return toInsertWeak } var ptr *T for { // Check the map. wp, ok := m.Load(value) if !ok { // Try to insert a new value into the map. wp, _ = m.LoadOrStore(value, newValue()) } // Now that we're sure there's a value in the map, let's // try to get the pointer we need out of it. ptr = wp.Strong() if ptr != nil { break }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed May 22 16:01:55 UTC 2024 - 5.3K bytes - Viewed (0) -
src/sync/map.go
// read and write operations are defined as follows. // [Map.Load], [Map.LoadAndDelete], [Map.LoadOrStore], [Map.Swap], [Map.CompareAndSwap], // and [Map.CompareAndDelete] are read operations; // [Map.Delete], [Map.LoadAndDelete], [Map.Store], and [Map.Swap] are write operations; // [Map.LoadOrStore] is a write operation when it returns loaded set to false;
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Fri Jun 07 21:14:51 UTC 2024 - 15.6K bytes - Viewed (0) -
src/go/internal/gcimporter/gcimporter.go
func lookupGorootExport(pkgDir string) (string, error) { f, ok := exportMap.Load(pkgDir) if !ok { var ( listOnce sync.Once exportPath string err error ) f, _ = exportMap.LoadOrStore(pkgDir, func() (string, error) { listOnce.Do(func() { cmd := exec.Command(filepath.Join(build.Default.GOROOT, "bin", "go"), "list", "-export", "-f", "{{.Export}}", pkgDir) cmd.Dir = build.Default.GOROOT
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Thu May 23 01:00:11 UTC 2024 - 6.4K bytes - Viewed (0) -
src/cmd/go/internal/par/work.go
// Do returns the value returned by the one call to f. func (c *Cache[K, V]) Do(key K, f func() V) V { entryIface, ok := c.m.Load(key) if !ok { entryIface, _ = c.m.LoadOrStore(key, new(cacheEntry[V])) } e := entryIface.(*cacheEntry[V]) if !e.done.Load() { e.mu.Lock() if !e.done.Load() { e.result = f() e.done.Store(true) } e.mu.Unlock() }
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Mon May 13 15:54:54 UTC 2024 - 4.3K bytes - Viewed (0) -
src/reflect/type.go
} // Look in known types. s := "*" + t.String() for _, tt := range typesByString(s) { p := (*ptrType)(unsafe.Pointer(tt)) if p.Elem != &t.t { continue } pi, _ := ptrMap.LoadOrStore(t, p) return &pi.(*ptrType).Type } // Create a new ptrType starting with the description // of an *unsafe.Pointer. var iptr any = (*unsafe.Pointer)(nil)
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed May 29 17:58:53 UTC 2024 - 85.5K bytes - Viewed (0) -
src/internal/concurrent/hashtriemap.go
i = n.indirect() } panic("internal/concurrent.HashMapTrie: ran out of hash bits while iterating") } // 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 (ht *HashTrieMap[K, V]) LoadOrStore(key K, value V) (result V, loaded bool) { hash := ht.keyHash(abi.NoEscape(unsafe.Pointer(&key)), ht.seed)
Registered: Wed Jun 12 16:32:35 UTC 2024 - Last Modified: Wed May 22 16:01:55 UTC 2024 - 11.8K bytes - Viewed (0) -
staging/src/k8s.io/apiserver/pkg/util/peerproxy/peerproxy_handler_test.go
ppI.addToStorageVersionMap(svdata.gvr, svdata.serverId) } return ppI, nil } func (h *peerProxyHandler) addToStorageVersionMap(gvr schema.GroupVersionResource, serverId string) { apiserversi, _ := h.svMap.LoadOrStore(gvr, &sync.Map{}) apiservers := apiserversi.(*sync.Map) if serverId != "" { apiservers.Store(serverId, true) } } func testDataExists(gvr schema.GroupVersionResource) bool {
Registered: Sat Jun 15 01:39:40 UTC 2024 - Last Modified: Wed Apr 24 18:25:29 UTC 2024 - 10.8K bytes - Viewed (0)