Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 6 of 6 for LoadOrStore (0.15 sec)

  1. 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)
  2. 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)
  3. 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)
  4. 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)
  5. 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)
  6. 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)
Back to top