github.com/puzpuzpuz/xsync/v3@v3.1.1-0.20240225193106-cbe4ec1e954f/export_test.go (about) 1 package xsync 2 3 const ( 4 EntriesPerMapBucket = entriesPerMapBucket 5 MapLoadFactor = mapLoadFactor 6 DefaultMinMapTableLen = defaultMinMapTableLen 7 DefaultMinMapTableCap = defaultMinMapTableLen * entriesPerMapBucket 8 MaxMapCounterLen = maxMapCounterLen 9 ) 10 11 type ( 12 BucketPadded = bucketPadded 13 BucketOfPadded = bucketOfPadded 14 ) 15 16 type MapStats struct { 17 mapStats 18 } 19 20 func CollectMapStats(m *Map) MapStats { 21 return MapStats{m.stats()} 22 } 23 24 func LockBucket(mu *uint64) { 25 lockBucket(mu) 26 } 27 28 func UnlockBucket(mu *uint64) { 29 unlockBucket(mu) 30 } 31 32 func TopHashMatch(hash, topHashes uint64, idx int) bool { 33 return topHashMatch(hash, topHashes, idx) 34 } 35 36 func StoreTopHash(hash, topHashes uint64, idx int) uint64 { 37 return storeTopHash(hash, topHashes, idx) 38 } 39 40 func EraseTopHash(topHashes uint64, idx int) uint64 { 41 return eraseTopHash(topHashes, idx) 42 } 43 44 func EnableAssertions() { 45 assertionsEnabled = true 46 } 47 48 func DisableAssertions() { 49 assertionsEnabled = false 50 } 51 52 func Fastrand() uint32 { 53 return runtime_fastrand() 54 } 55 56 func NextPowOf2(v uint32) uint32 { 57 return nextPowOf2(v) 58 } 59 60 func MakeSeed() uint64 { 61 return makeSeed() 62 } 63 64 func HashString(s string, seed uint64) uint64 { 65 return hashString(s, seed) 66 } 67 68 func MakeHasher[T comparable]() func(T, uint64) uint64 { 69 return makeHasher[T]() 70 } 71 72 func CollectMapOfStats[K comparable, V any](m *MapOf[K, V]) MapStats { 73 return MapStats{m.stats()} 74 } 75 76 func NewMapOfPresizedWithHasher[K comparable, V any]( 77 hasher func(K, uint64) uint64, 78 sizeHint int, 79 ) *MapOf[K, V] { 80 return newMapOfPresized[K, V](hasher, sizeHint) 81 }