Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 40 for LoadOrStore (0.16 sec)

  1. src/sync/map_bench_test.go

    			for ; pb.Next(); i++ {
    				m.LoadOrStore(i, i)
    			}
    		},
    	})
    }
    
    func BenchmarkLoadOrStoreCollision(b *testing.B) {
    	benchMap(b, bench{
    		setup: func(_ *testing.B, m mapInterface) {
    			m.LoadOrStore(0, 0)
    		},
    
    		perG: func(b *testing.B, pb *testing.PB, i int, m mapInterface) {
    			for ; pb.Next(); i++ {
    				m.LoadOrStore(0, 0)
    			}
    		},
    	})
    }
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Feb 01 15:34:22 UTC 2024
    - 11.5K bytes
    - Viewed (0)
  2. 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)
  3. 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)
  4. schema/pool.go

    package schema
    
    import (
    	"reflect"
    	"sync"
    )
    
    // sync pools
    var (
    	normalPool      sync.Map
    	poolInitializer = func(reflectType reflect.Type) FieldNewValuePool {
    		v, _ := normalPool.LoadOrStore(reflectType, &sync.Pool{
    			New: func() interface{} {
    				return reflect.New(reflectType).Interface()
    			},
    		})
    		return v.(FieldNewValuePool)
    	}
    Registered: Wed Jun 12 16:27:09 UTC 2024
    - Last Modified: Mon Apr 11 13:37:44 UTC 2022
    - 345 bytes
    - Viewed (0)
  5. 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)
  6. src/sync/map_reference_test.go

    )
    
    // This file contains reference map implementations for unit-tests.
    
    // mapInterface is the interface Map implements.
    type mapInterface interface {
    	Load(key any) (value any, ok bool)
    	Store(key, value any)
    	LoadOrStore(key, value any) (actual any, loaded bool)
    	LoadAndDelete(key any) (value any, loaded bool)
    	Delete(any)
    	Swap(key, value any) (previous any, loaded bool)
    	CompareAndSwap(key, old, new any) (swapped bool)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Feb 01 15:34:22 UTC 2024
    - 5.6K bytes
    - Viewed (0)
  7. src/archive/zip/register.go

    	if _, dup := decompressors.LoadOrStore(method, dcomp); dup {
    		panic("decompressor already registered")
    	}
    }
    
    // RegisterCompressor registers custom compressors for a specified method ID.
    // The common methods [Store] and [Deflate] are built in.
    func RegisterCompressor(method uint16, comp Compressor) {
    	if _, dup := compressors.LoadOrStore(method, comp); dup {
    		panic("compressor already registered")
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Oct 13 18:36:46 UTC 2023
    - 3.7K bytes
    - Viewed (0)
  8. src/cmd/vendor/golang.org/x/mod/sumdb/cache.go

    // Do returns the value returned by the one call to f.
    func (c *parCache) Do(key interface{}, f func() interface{}) interface{} {
    	entryIface, ok := c.m.Load(key)
    	if !ok {
    		entryIface, _ = c.m.LoadOrStore(key, new(cacheEntry))
    	}
    	e := entryIface.(*cacheEntry)
    	if atomic.LoadUint32(&e.done) == 0 {
    		e.mu.Lock()
    		if atomic.LoadUint32(&e.done) == 0 {
    			e.result = f()
    			atomic.StoreUint32(&e.done, 1)
    		}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue Oct 29 20:10:15 UTC 2019
    - 1.5K bytes
    - Viewed (0)
  9. src/sync/map_test.go

    	"runtime"
    	"sync"
    	"sync/atomic"
    	"testing"
    	"testing/quick"
    )
    
    type mapOp string
    
    const (
    	opLoad             = mapOp("Load")
    	opStore            = mapOp("Store")
    	opLoadOrStore      = mapOp("LoadOrStore")
    	opLoadAndDelete    = mapOp("LoadAndDelete")
    	opDelete           = mapOp("Delete")
    	opSwap             = mapOp("Swap")
    	opCompareAndSwap   = mapOp("CompareAndSwap")
    	opCompareAndDelete = mapOp("CompareAndDelete")
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Feb 01 15:34:22 UTC 2024
    - 8.1K bytes
    - Viewed (0)
  10. src/cmd/go/scriptcmds_test.go

    		t, ok := tbFromContext(state.Context())
    		if !ok {
    			return nil, errors.New("script Context unexpectedly missing testing.TB key")
    		}
    		_, dup := scriptGoInvoked.LoadOrStore(t, true)
    		if !dup {
    			t.Cleanup(func() { scriptGoInvoked.Delete(t) })
    		}
    		return cmd.Run(state, s...)
    	})
    }
    
    // scriptStale checks that the named build targets are stale.
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Mar 07 18:33:17 UTC 2024
    - 3.3K bytes
    - Viewed (0)
Back to top