structure

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConcurrentMap

type ConcurrentMap[Key KeyType, Val any] struct {
	// contains filtered or unexported fields
}

ConcurrentMap represents safe concurrent map container

func NewConcurrentMap

func NewConcurrentMap[Key KeyType, T any]() *ConcurrentMap[Key, T]

func (*ConcurrentMap[Key, T]) Del added in v1.1.5

func (container *ConcurrentMap[Key, T]) Del(key Key)

Del remove keys from container

func (*ConcurrentMap[Key, T]) Find

func (container *ConcurrentMap[Key, T]) Find(key Key) (item T, err error)

Find returns item if key is not exist, returns not found error

func (*ConcurrentMap[Key, T]) Get

func (container *ConcurrentMap[Key, T]) Get(key Key) (item T, exist bool)

Get return item and exist

func (*ConcurrentMap[Key, T]) Set

func (container *ConcurrentMap[Key, T]) Set(key Key, value T)

Set sets map item

type KeyType added in v1.1.5

type KeyType interface {
	int | int16 | int32 | int64 | string
}

type Queue added in v1.1.7

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

Queue represents a queue of any object

func NewQueue added in v1.1.7

func NewQueue[T any](size int) *Queue[T]

NewQueue returns a new queue with the given size

func (*Queue[T]) Empty added in v1.1.7

func (queue *Queue[T]) Empty() bool

Empty returns true if the queue is empty

func (*Queue[T]) Length added in v1.1.7

func (queue *Queue[T]) Length() int

Length returns the length of queue

func (*Queue[T]) Offer added in v1.1.7

func (queue *Queue[T]) Offer(items ...T)

Offer push the active fd to the queue, it will be deposed when queue is full

func (*Queue[T]) Polling added in v1.1.7

func (queue *Queue[T]) Polling(stopCh <-chan struct{}, handler func(item T))

Polling poll with callback function

type Sharding added in v1.1.7

type Sharding[T any] []T

func NewSharding added in v1.1.7

func NewSharding[T any](size int, constructor func() T) Sharding[T]

func (Sharding[T]) GetShard added in v1.1.7

func (shard Sharding[T]) GetShard(num int) T

func (Sharding[T]) Iterator added in v1.1.7

func (shard Sharding[T]) Iterator(iterator func(T))

type Singleton added in v1.1.7

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

func NewSingleton added in v1.1.7

func NewSingleton[T any](constructor func() T) *Singleton[T]

func (*Singleton[T]) Get added in v1.1.7

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

Jump to

Keyboard shortcuts

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