concurrent

package module
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: MIT Imports: 3 Imported by: 1

README

Go Report Card

go-concurrent

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Collection

type Collection interface {
	// Size returns the collection size
	Size() int

	// Clear clears the collection
	Clear()
}

Collection defines generic collection.

type Equals added in v0.0.10

type Equals func(l, r interface{}) bool

Equals indicates whether l is "equal to" r.

type IdleStrategy added in v0.0.6

type IdleStrategy interface {
	// Idle performs idle action
	Idle()
}

IdleStrategy is used when there is no work to do

func NewSleepingIdleStrategy added in v0.0.6

func NewSleepingIdleStrategy(d time.Duration) IdleStrategy

NewSleepingIdleStrategy returns a new instance of sleepingIdleStrategy. Duration d defines the execution pause.

func NewYeildingIdleStrategy added in v0.0.6

func NewYeildingIdleStrategy() IdleStrategy

NewYeildingIdleStrategy returns a new instance of yeildingIdleStrategy

type List

type List interface {
	Collection

	// Add adds the element e into the List.
	Add(e interface{})

	// Get returns the element specified by its index i.
	Get(i int) interface{}

	// Remove the first occurrence of the element e from the list if it is present.
	Remove(e interface{}, eq Equals) bool

	// Range calls f sequentially for each element present in the list.
	// If f returns false, range stops the iteration.
	Range(f func(e interface{}) bool)
}

List defines ordered collection of elements which may contain duplicates.

type Map

type Map interface {
	Collection

	// Put puts a new key-value pair into the Map.
	// If the key already exists overwrites the existing value with the new one.
	// Returns the previous value associated with key, or nil if there was no mapping
	// for key.
	Put(k interface{}, v interface{}) interface{}

	// PutIfAbsent puts the key-value pair (and returns true)
	// only if the key is absent, otherwise it returns false.
	PutIfAbsent(k interface{}, v interface{}) bool

	// ComputeIfAbsent computes the mapping function f and inserts its value
	// (unless nil) under the key k, if the key does not exist and.
	// Returns the mapping and the flag indicating if the mapping was created.
	ComputeIfAbsent(k interface{}, f func() interface{}) (interface{}, bool)

	// Contains returns true if the map contains the key k.
	Contains(k interface{}) bool

	// Get returns the value specified by the key if the key-value pair is
	// present, othervise returns nil.
	Get(k interface{}) interface{}

	// Range calls f sequentially for each key and value present in the map.
	// If f returns false, range stops the iteration.
	Range(f func(k, v interface{}) bool)

	// Remove removes the key-value pair specified by the key k from the map
	// if it is present.
	Remove(k interface{})

	// Keys returns the keys contained in the map.
	Keys() []interface{}
}

Map represents a collection of key-value pairs.

type Queue

type Queue interface {
	Collection

	// Offer inserts the element e into the Queue.
	Offer(e interface{})

	// Poll retrieves and removes the head of the Queue; returns nil if the
	// queue is empty.
	Poll() interface{}

	// Peek retrieves, but does not remove, the head of the queue; returns nil
	// if the queue is empty.
	Peek() interface{}

	// Range calls f sequentially for each element present in the queue.
	// If f returns false, range stops the iteration.
	Range(f func(e interface{}) bool)
}

Queue defines ordered in FIFO manner collection of elements which may contain duplicates.

type Set

type Set interface {
	Collection

	// Add adds the element e into the set.
	Add(e interface{})

	// Contains returns true if the set contains the element e.
	Contains(e interface{}) bool

	// Range calls f sequentially for each element present in the set.
	// If f returns false, range stops the iteration.
	Range(f func(e interface{}) bool)

	// Remove removes the element e from the set if it is present.
	Remove(e interface{})
}

Set defines unordered collection of element which may not contain duplicates.

func NewSynchronizedSet

func NewSynchronizedSet(capacity int) Set

NewSynchronizedSet returns pointer to a new SynchronizedSet instance

type SynchronizedList

type SynchronizedList struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SynchronizedList is a safe for concurrent use List implementation

func NewSynchronizedList

func NewSynchronizedList(capacity int) *SynchronizedList

NewSynchronizedList returns pointer to a new SynchronizedList instance

func (*SynchronizedList) Add

func (l *SynchronizedList) Add(v interface{})

Add implements List.Clear

func (*SynchronizedList) Clear

func (l *SynchronizedList) Clear()

Clear implements List.Clear

func (*SynchronizedList) Get

func (l *SynchronizedList) Get(i int) interface{}

Get implements List.Clear

func (*SynchronizedList) Range added in v0.0.13

func (l *SynchronizedList) Range(f func(e interface{}) bool)

Range implements List.Range

func (*SynchronizedList) Remove added in v0.0.10

func (l *SynchronizedList) Remove(e interface{}, eq Equals) bool

Remove implements List.Remove

func (*SynchronizedList) Size

func (l *SynchronizedList) Size() int

Size implements List.Size

type SynchronizedMap

type SynchronizedMap struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SynchronizedMap is a safe for concurrent use Map implementation.

func NewSynchronizedMap

func NewSynchronizedMap(capacity int) *SynchronizedMap

NewSynchronizedMap returns pointer to a new SynchronizedMap instance.

func (*SynchronizedMap) Clear

func (m *SynchronizedMap) Clear()

Clear implements Map.Clear.

func (*SynchronizedMap) ComputeIfAbsent added in v0.0.11

func (m *SynchronizedMap) ComputeIfAbsent(k interface{}, f func() interface{}) (interface{}, bool)

ComputeIfAbsent implements Map.ComputeIfAbsent.

func (*SynchronizedMap) Contains added in v0.0.7

func (m *SynchronizedMap) Contains(k interface{}) bool

Contains implements Map.Contains.

func (*SynchronizedMap) Get

func (m *SynchronizedMap) Get(k interface{}) interface{}

Get implements Map.Get.

func (*SynchronizedMap) Keys added in v0.0.9

func (m *SynchronizedMap) Keys() []interface{}

Keys implements Map.Keys.

func (*SynchronizedMap) Put

func (m *SynchronizedMap) Put(k interface{}, v interface{}) interface{}

Put implements Map.Put.

func (*SynchronizedMap) PutIfAbsent

func (m *SynchronizedMap) PutIfAbsent(k interface{}, v interface{}) bool

PutIfAbsent implements Map.PutIfAbsent.

func (*SynchronizedMap) Range added in v0.0.3

func (m *SynchronizedMap) Range(f func(k, v interface{}) bool)

Range implements Map.Range.

func (*SynchronizedMap) Remove added in v0.0.7

func (m *SynchronizedMap) Remove(k interface{})

Remove implements Map.Remove.

func (*SynchronizedMap) Size

func (m *SynchronizedMap) Size() int

Size implements Map.Size.

type SynchronizedRingQueue

type SynchronizedRingQueue struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SynchronizedRingQueue is a safe for concurrent use Queue implementation

func NewSynchronizedRingQueue

func NewSynchronizedRingQueue(initialCapacity int) *SynchronizedRingQueue

NewSynchronizedRingQueue returns pointer to a new SynchronizedRingQueue instance

func (*SynchronizedRingQueue) Capacity

func (q *SynchronizedRingQueue) Capacity() int

Capacity implements Queue.Capacity

func (*SynchronizedRingQueue) Clear

func (q *SynchronizedRingQueue) Clear()

Clear implements Queue.Clear

func (*SynchronizedRingQueue) Offer

func (q *SynchronizedRingQueue) Offer(e interface{})

Offer implements Queue.Offer

func (*SynchronizedRingQueue) Peek

func (q *SynchronizedRingQueue) Peek() interface{}

Peek implements Queue.Peek

func (*SynchronizedRingQueue) Poll

func (q *SynchronizedRingQueue) Poll() interface{}

Poll implements Queue.Poll

func (*SynchronizedRingQueue) Range added in v0.0.15

func (q *SynchronizedRingQueue) Range(f func(e interface{}) bool)

Range implements Queue.Range

func (*SynchronizedRingQueue) Size

func (q *SynchronizedRingQueue) Size() int

Size implements Queue.Size

type SynchronizedSet

type SynchronizedSet struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

SynchronizedSet is a safe for concurrent use Set implementation

func (*SynchronizedSet) Add

func (s *SynchronizedSet) Add(v interface{})

Add implements Set.Add

func (*SynchronizedSet) Clear

func (s *SynchronizedSet) Clear()

Clear implements Set.Clear

func (*SynchronizedSet) Contains

func (s *SynchronizedSet) Contains(v interface{}) bool

Contains implements Set.Contains

func (*SynchronizedSet) Range added in v0.0.7

func (s *SynchronizedSet) Range(f func(e interface{}) bool)

Range implements Set.Range

func (*SynchronizedSet) Remove added in v0.0.7

func (s *SynchronizedSet) Remove(k interface{})

Remove implements Set.Remove

func (*SynchronizedSet) Size

func (s *SynchronizedSet) Size() int

Size implements Set.Size

Jump to

Keyboard shortcuts

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