mutexmap

package module
v0.0.0-...-8287ccf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 1 Imported by: 0

README

mutexmap

MutexMap provides a generics-based go standard map protected by a RWMutex. It exposes the same methods as sync.Map but with better type safety and performance in scenarios with up to four cores. For benchmarks with sync.Map compare (https://medium.com/@deckarep/the-new-kid-in-town-gos-sync-map-de24a6bf7c2c)

Usage

Create a new MutexMap with string keys and *http.Client values
m := NewMutexMap[string, *http.Client]()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MutexMap

type MutexMap[K comparable, V any] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

MutexMap provides a go standard map protected by a RWMutex. It exposes the same methods as sync.Map but with better type safety and performance in scenarios with up to four cores. Type parameter K for the map's key and type parameter V for the map's values. For benchmarks compare: https://medium.com/@deckarep/the-new-kid-in-town-gos-sync-map-de24a6bf7c2c

func NewMutexMap

func NewMutexMap[K comparable, V any]() *MutexMap[K, V]

func (*MutexMap[K, _]) Delete

func (m *MutexMap[K, _]) Delete(key K)

func (*MutexMap[K, V]) Load

func (m *MutexMap[K, V]) Load(key K) (V, bool)

func (*MutexMap[K, V]) LoadAndDelete

func (m *MutexMap[K, V]) LoadAndDelete(key K) (V, bool)

func (*MutexMap[K, V]) LoadOrStore

func (m *MutexMap[K, V]) LoadOrStore(key K, val V) (V, bool)

func (*MutexMap[K, V]) Range

func (m *MutexMap[K, V]) Range(f func(key K, value V) bool)

func (*MutexMap[K, V]) Store

func (m *MutexMap[K, V]) Store(key K, val V)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL