guc

package module
v0.0.0-...-eb29266 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: MIT Imports: 10 Imported by: 1

README

GUC

concurrent util for golang

Documentation

Index

Constants

View Source
const (
	CacheLineSize = 64
)

FIXME!

Variables

This section is empty.

Functions

func C128equal

func C128equal(p, q unsafe.Pointer) bool

func C128hash

func C128hash(p unsafe.Pointer, h uintptr) uintptr

func C64equal

func C64equal(p, q unsafe.Pointer) bool

func C64hash

func C64hash(p unsafe.Pointer, h uintptr) uintptr

func F32equal

func F32equal(p, q unsafe.Pointer) bool

func F32hash

func F32hash(p unsafe.Pointer, h uintptr) uintptr

func F64equal

func F64equal(p, q unsafe.Pointer) bool

func F64hash

func F64hash(p unsafe.Pointer, h uintptr) uintptr

func Fastrand

func Fastrand() uint32

func Interequal

func Interequal(p, q unsafe.Pointer) bool

func Interhash

func Interhash(p unsafe.Pointer, h uintptr) uintptr

func Memequal0

func Memequal0(p, q unsafe.Pointer) bool

func Memequal128

func Memequal128(p, q unsafe.Pointer) bool

func Memequal16

func Memequal16(p, q unsafe.Pointer) bool

func Memequal32

func Memequal32(p, q unsafe.Pointer) bool

func Memequal64

func Memequal64(p, q unsafe.Pointer) bool

func Memequal8

func Memequal8(p, q unsafe.Pointer) bool

func Memhash0

func Memhash0(p unsafe.Pointer, h uintptr) uintptr

func Memhash128

func Memhash128(p unsafe.Pointer, h uintptr) uintptr

func Memhash16

func Memhash16(p unsafe.Pointer, h uintptr) uintptr

func Memhash32

func Memhash32(p unsafe.Pointer, seed uintptr) uintptr

func Memhash64

func Memhash64(p unsafe.Pointer, seed uintptr) uintptr

func Memhash8

func Memhash8(p unsafe.Pointer, h uintptr) uintptr

func Nilinterequal

func Nilinterequal(p, q unsafe.Pointer) bool

func Nilinterhash

func Nilinterhash(p unsafe.Pointer, h uintptr) uintptr

func Strequal

func Strequal(p, q unsafe.Pointer) bool

func Strhash

func Strhash(a unsafe.Pointer, h uintptr) uintptr

func SyncRuntimeCanSpin

func SyncRuntimeCanSpin(i int) bool

Active spinning runtime support. runtime_canSpin returns true is spinning makes sense at the moment.

func SyncRuntimeDoSpin

func SyncRuntimeDoSpin()

runtime_doSpin does active spinning.

func SyncRuntimeNanoTime

func SyncRuntimeNanoTime() int64

nanotime

func SyncRuntimeSemacquire

func SyncRuntimeSemacquire(s *uint32)

Semacquire waits until *s > 0 and then atomically decrements it. It is intended as a simple sleep primitive for use by the synchronization library and should not be used directly.

func SyncRuntimeSemacquireMutex

func SyncRuntimeSemacquireMutex(s *uint32, lifo bool)

SemacquireMutex is like Semacquire, but for profiling contended Mutexes. If lifo is true, queue waiter at the head of wait queue.

func SyncRuntimeSemrelease

func SyncRuntimeSemrelease(s *uint32, handoff bool)

Semrelease atomically increments *s and notifies a waiting goroutine if one is blocked in Semacquire. It is intended as a simple wakeup primitive for use by the synchronization library and should not be used directly. If handoff is true, pass count directly to the first waiter.

Types

type BlockingQueue

type BlockingQueue interface {
	Queue

	Put(i interface{})
	OfferWithTimeout(i interface{}, t time.Duration) bool
	Take() interface{}
	PollWithTimeout(t time.Duration) interface{}
	RemainingCapacity() int
	DrainTo(coll Collection) int
	DrainToWithLimit(coll Collection, max int) int
}

type Collection

type Collection interface {
	Iterable
	Size() int
	IsEmpty() bool
	Contains(i interface{}) bool
	ToArray() []interface{}
	FillArray(arr []interface{}) []interface{}

	Add(i interface{}) bool
	Remove(i interface{}) bool
	ContainsAll(coll Collection) bool
	AddAll(coll Collection) bool
	RemoveAll(coll Collection) bool
	RemoveIf(predicate func(i interface{}) bool) bool
	RetainAll(coll Collection) bool
	Clear()
	Equals(i interface{}) bool
	HashCode() int
}

type Comparable

type Comparable interface {
	CompareTo(i interface{}) int
}

this interface is used for ordering the objects of each struct

type Comparator

type Comparator interface {
	Compare(o1, o2 interface{}) int
}

this interface represents the function that compares two objects

type ConcurrentHashMap

type ConcurrentHashMap struct {
	// contains filtered or unexported fields
}

TODO list 1. LongAdder like total count 2. bucket tree degenerate, ps: golang has no build-in comparable interface 3. iterator 4. multi-goroutine cooperate resize

func NewConcurrentHashMap

func NewConcurrentHashMap(initialCapacity, concurrencyLevel int32) *ConcurrentHashMap

func (*ConcurrentHashMap) Contains

func (m *ConcurrentHashMap) Contains(key interface{}) bool

func (*ConcurrentHashMap) IsEmpty

func (m *ConcurrentHashMap) IsEmpty() bool

func (*ConcurrentHashMap) Load

func (m *ConcurrentHashMap) Load(key interface{}) (interface{}, bool)

func (*ConcurrentHashMap) Size

func (m *ConcurrentHashMap) Size() int

func (*ConcurrentHashMap) Store

func (m *ConcurrentHashMap) Store(key, value interface{}) interface{}

type CounterCell

type CounterCell struct {
	// contains filtered or unexported fields
}

type Iterable

type Iterable interface {
	Iterator() Iterator
	ForEach(consumer func(i interface{}))
}

type Iterator

type Iterator interface {
	HasNext() bool
	Next() interface{}
	Remove()
	ForEachRemaining(consumer func(i interface{}))
}

type Object

type Object interface {
	Equals(i interface{}) bool
}

this interface imposes basic operations on objects

type PriorityBlockingQueue

type PriorityBlockingQueue struct {
	// contains filtered or unexported fields
}

func NewPriorityBlockingQueue

func NewPriorityBlockingQueue() *PriorityBlockingQueue

func NewPriorityBlockingQueueWithComparator

func NewPriorityBlockingQueueWithComparator(comparator Comparator) *PriorityBlockingQueue

func (*PriorityBlockingQueue) Add

func (this *PriorityBlockingQueue) Add(i interface{}) bool

func (*PriorityBlockingQueue) AddAll

func (this *PriorityBlockingQueue) AddAll(coll Collection) bool

func (*PriorityBlockingQueue) Clear

func (this *PriorityBlockingQueue) Clear()

func (*PriorityBlockingQueue) Contains

func (this *PriorityBlockingQueue) Contains(i interface{}) bool

func (*PriorityBlockingQueue) ContainsAll

func (this *PriorityBlockingQueue) ContainsAll(coll Collection) bool

func (*PriorityBlockingQueue) DrainTo

func (this *PriorityBlockingQueue) DrainTo(coll Collection) int

func (*PriorityBlockingQueue) DrainToWithLimit

func (this *PriorityBlockingQueue) DrainToWithLimit(coll Collection, total int) int

func (*PriorityBlockingQueue) Element

func (this *PriorityBlockingQueue) Element() interface{}

func (*PriorityBlockingQueue) Equals

func (this *PriorityBlockingQueue) Equals(i interface{}) bool

func (*PriorityBlockingQueue) FillArray

func (this *PriorityBlockingQueue) FillArray(arr []interface{}) []interface{}

func (*PriorityBlockingQueue) ForEach

func (this *PriorityBlockingQueue) ForEach(consumer func(i interface{}))

func (*PriorityBlockingQueue) HashCode

func (this *PriorityBlockingQueue) HashCode() int

func (*PriorityBlockingQueue) IsEmpty

func (this *PriorityBlockingQueue) IsEmpty() bool

func (*PriorityBlockingQueue) Iterator

func (this *PriorityBlockingQueue) Iterator() Iterator

func (*PriorityBlockingQueue) Offer

func (this *PriorityBlockingQueue) Offer(i interface{}) bool

func (*PriorityBlockingQueue) OfferWithTimeout

func (this *PriorityBlockingQueue) OfferWithTimeout(i interface{}, t time.Duration) bool

func (*PriorityBlockingQueue) Peek

func (this *PriorityBlockingQueue) Peek() interface{}

func (*PriorityBlockingQueue) Poll

func (this *PriorityBlockingQueue) Poll() interface{}

func (*PriorityBlockingQueue) PollWithTimeout

func (this *PriorityBlockingQueue) PollWithTimeout(t time.Duration) interface{}

func (*PriorityBlockingQueue) Put

func (this *PriorityBlockingQueue) Put(i interface{})

func (*PriorityBlockingQueue) RemainingCapacity

func (this *PriorityBlockingQueue) RemainingCapacity() int

func (*PriorityBlockingQueue) Remove

func (this *PriorityBlockingQueue) Remove(i interface{}) bool

func (*PriorityBlockingQueue) RemoveAll

func (this *PriorityBlockingQueue) RemoveAll(coll Collection) bool

func (*PriorityBlockingQueue) RemoveHead

func (this *PriorityBlockingQueue) RemoveHead() interface{}

func (*PriorityBlockingQueue) RemoveIf

func (this *PriorityBlockingQueue) RemoveIf(predicate func(i interface{}) bool) bool

func (*PriorityBlockingQueue) RetainAll

func (this *PriorityBlockingQueue) RetainAll(coll Collection) bool

func (*PriorityBlockingQueue) Size

func (this *PriorityBlockingQueue) Size() int

func (*PriorityBlockingQueue) Take

func (this *PriorityBlockingQueue) Take() interface{}

func (*PriorityBlockingQueue) ToArray

func (this *PriorityBlockingQueue) ToArray() []interface{}

type PriorityQueue

type PriorityQueue struct {
	// contains filtered or unexported fields
}

func NewPriority

func NewPriority() *PriorityQueue

func NewPriorityWithComparator

func NewPriorityWithComparator(comparator Comparator) *PriorityQueue

func (*PriorityQueue) Add

func (this *PriorityQueue) Add(i interface{}) bool

func (*PriorityQueue) AddAll

func (this *PriorityQueue) AddAll(coll Collection) bool

func (*PriorityQueue) Clear

func (this *PriorityQueue) Clear()

func (*PriorityQueue) Contains

func (this *PriorityQueue) Contains(i interface{}) bool

func (*PriorityQueue) ContainsAll

func (this *PriorityQueue) ContainsAll(coll Collection) bool

func (*PriorityQueue) Element

func (this *PriorityQueue) Element() interface{}

func (*PriorityQueue) Equals

func (this *PriorityQueue) Equals(i interface{}) bool

func (*PriorityQueue) FillArray

func (this *PriorityQueue) FillArray(arr []interface{}) []interface{}

func (*PriorityQueue) ForEach

func (this *PriorityQueue) ForEach(consumer func(i interface{}))

func (*PriorityQueue) HashCode

func (this *PriorityQueue) HashCode() int

func (*PriorityQueue) IsEmpty

func (this *PriorityQueue) IsEmpty() bool

func (*PriorityQueue) Iterator

func (this *PriorityQueue) Iterator() Iterator

func (*PriorityQueue) Offer

func (this *PriorityQueue) Offer(i interface{}) bool

func (*PriorityQueue) Peek

func (this *PriorityQueue) Peek() interface{}

func (*PriorityQueue) Poll

func (this *PriorityQueue) Poll() interface{}

func (*PriorityQueue) Remove

func (this *PriorityQueue) Remove(item interface{}) bool

func (*PriorityQueue) RemoveAll

func (this *PriorityQueue) RemoveAll(coll Collection) bool

func (*PriorityQueue) RemoveHead

func (this *PriorityQueue) RemoveHead() interface{}

func (*PriorityQueue) RemoveIf

func (this *PriorityQueue) RemoveIf(predicate func(i interface{}) bool) bool

func (*PriorityQueue) RetainAll

func (this *PriorityQueue) RetainAll(coll Collection) bool

func (*PriorityQueue) Size

func (this *PriorityQueue) Size() int

func (*PriorityQueue) ToArray

func (this *PriorityQueue) ToArray() []interface{}

type Queue

type Queue interface {
	Collection

	Offer(i interface{}) bool
	// retrieve and remove head
	// panic if empty
	RemoveHead() interface{}
	// retrieve and remove head
	// return nil if empty
	Poll() interface{}
	// retrieve head of the queue
	// panic if empty
	Element() interface{}
	// retrieve head of the queue
	// return nil if empty
	Peek() interface{}
}

Jump to

Keyboard shortcuts

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