containers

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: ISC Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IDTable

type IDTable[T any] map[uint64]T

IDTable is a map with random indexes for jobs and other cases where a random but unique index is required

func (IDTable[T]) Assign

func (id IDTable[T]) Assign(val T) uint64

Assign adds an object to the map and returns its assigned index

type RWSync

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

RWSync wraps any value in a RWMutex for safe concurrent use. Unlike Sync, concurrent read access is allowed (so don't use it for things like maps and pointers!)

func NewRWSync

func NewRWSync[T any](val T) *RWSync[T]

NewRWSync creates a new RWSync wrapper with a predefined value

func (*RWSync[T]) Get

func (s *RWSync[T]) Get() T

Get reads the wrapped value contained

func (*RWSync[T]) Set

func (s *RWSync[T]) Set(val T)

Set sets the value wrapped by the object

type RWSyncMap

type RWSyncMap[K comparable, T any] RWSync[map[K]T]

RWSyncMap is a map wrapped in a mutex for safe concurrent use Unlike Sync, concurrent read access is allowed (so don't use it for things like maps and pointers!)

func NewRWSyncMap

func NewRWSyncMap[K comparable, T any]() *RWSyncMap[K, T]

NewRWSyncMap creates a new RWSync object with an empty map

func (*RWSyncMap[K, T]) Copy added in v0.0.3

func (s *RWSyncMap[K, T]) Copy() map[K]T

Copy returns a shallow copy of the wrapped map

func (*RWSyncMap[K, T]) DeleteKey

func (s *RWSyncMap[K, T]) DeleteKey(key K)

DeleteKey removes a key from the wrapped map

func (*RWSyncMap[K, T]) GetKey

func (s *RWSyncMap[K, T]) GetKey(key K) T

GetKey reads a key from the wrapper map

func (*RWSyncMap[K, T]) SetKey

func (s *RWSyncMap[K, T]) SetKey(key K, val T)

SetKey sets a value to the wrapped map

type Sync

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

Sync wraps any value in a mutex for safe concurrent use

func NewSync

func NewSync[T any](val T) *Sync[T]

NewSync creates a new Sync wrapper with a predefined value

func (*Sync[T]) Get

func (s *Sync[T]) Get() T

Get reads the wrapped value contained

func (*Sync[T]) Set

func (s *Sync[T]) Set(val T)

Set sets the value wrapped by the object

type SyncMap

type SyncMap[K comparable, T any] Sync[map[K]T]

SyncMap is a map wrapped in a mutex for safe concurrent use

func NewSyncMap

func NewSyncMap[K comparable, T any]() *SyncMap[K, T]

NewSyncMap creates a new Sync object with an empty map

func (*SyncMap[K, T]) Copy added in v0.0.3

func (s *SyncMap[K, T]) Copy() map[K]T

Copy returns a shallow copy of the wrapped map

func (*SyncMap[K, T]) DeleteKey

func (s *SyncMap[K, T]) DeleteKey(key K)

DeleteKey removes a key from the wrapped map

func (*SyncMap[K, T]) GetKey

func (s *SyncMap[K, T]) GetKey(key K) T

GetKey reads a key from the wrapper map

func (*SyncMap[K, T]) SetKey

func (s *SyncMap[K, T]) SetKey(key K, val T)

SetKey sets a value to the wrapped map

Jump to

Keyboard shortcuts

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