package sync

import "github.com/redhatinsights/yggdrasil/internal/sync"

Index

Types

type RWMutexMap

type RWMutexMap[T any] struct {
	// contains filtered or unexported fields
}

RWMutexMap is a concurrency-safe map, using a sync.RWMutex to lock a backing map when accessing values.

func (*RWMutexMap[T]) Del

func (m *RWMutexMap[T]) Del(k string)

Del sets a read-write lock on the map and deletes the value for k from it.

func (*RWMutexMap[T]) Get

func (m *RWMutexMap[T]) Get(k string) (T, bool)

Get sets a read lock on the map, retrieving the value for k. A second return value indicates whether the key was present in the map.

func (*RWMutexMap[T]) Set

func (m *RWMutexMap[T]) Set(k string, t T)

Set locks the map, setting the key k to the value t.

func (*RWMutexMap[T]) Visit

func (m *RWMutexMap[T]) Visit(f func(k string, v T))

Visit read-locks the map and calls the function f for each member.

Source Files

mutex_map.go

Version
v0.4.5 (latest)
Published
Feb 3, 2025
Platform
linux/amd64
Imports
1 packages
Last checked
3 weeks ago

Tools for package owners.