threadsafe

package
v3.2.1-rc.2 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package threadsafe contains generic containers that are protected either by Mutexes or atomics underneath the hood.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map[K comparable, V any] struct {
	// contains filtered or unexported fields
}

Map implements a simple thread-safe map protected by a mutex.

func NewThreadSafeMap

func NewThreadSafeMap[K comparable, V any](m map[K]V) *Map[K, V]

NewThreadSafeMap returns a thread-safe map instance from a normal map.

func (*Map[K, V]) Delete

func (m *Map[K, V]) Delete(k K)

Delete an item from a thread-safe map.

func (*Map[K, V]) Get

func (m *Map[K, V]) Get(k K) (V, bool)

Get an item from a thread-safe map.

func (*Map[K, V]) Keys

func (m *Map[K, V]) Keys() []K

Keys returns the keys of a thread-safe map.

func (*Map[K, V]) Len

func (m *Map[K, V]) Len() int

Len of the thread-safe map.

func (*Map[K, V]) Put

func (m *Map[K, V]) Put(k K, v V)

Put an item into a thread-safe map.

Jump to

Keyboard shortcuts

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