sync

package
v0.0.0-...-cde7289 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Group) Do

func (g *Group) Do(key string, fn func() (any, error)) (any, error)

type Mutex

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

func NewMutex

func NewMutex() *Mutex

func (*Mutex) IsLocked

func (m *Mutex) IsLocked() bool

func (*Mutex) Lock

func (m *Mutex) Lock()

func (*Mutex) LockWithTimeout

func (m *Mutex) LockWithTimeout(timeout time.Duration) bool

func (*Mutex) TryLock

func (m *Mutex) TryLock() bool

func (*Mutex) Unlock

func (m *Mutex) Unlock()

type MutexInfo

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

func NewMutexInfo

func NewMutexInfo(m *sync.Mutex) *MutexInfo

func (*MutexInfo) Count

func (m *MutexInfo) Count() int

Count returns the number of goroutines waiting on the mutex

func (*MutexInfo) IsLocked

func (m *MutexInfo) IsLocked() bool

IsLocked returns true if the mutex is locked

func (*MutexInfo) IsStarving

func (m *MutexInfo) IsStarving() bool

IsStarving returns true if the mutex is starving

func (*MutexInfo) IsWoken

func (m *MutexInfo) IsWoken() bool

IsWoken returns true if the mutex is woken

type Once

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

func (*Once) Do

func (o *Once) Do(f func() error) error

type Queue

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

Queue lock-free的queue

func NewQueue

func NewQueue() *Queue

func (*Queue) Dequeue

func (q *Queue) Dequeue() any

Dequeue 出队,没有元素则返回nil

func (*Queue) Enqueue

func (q *Queue) Enqueue(v any)

Enqueue 入队

type ReentrantLock

type ReentrantLock struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*ReentrantLock) Lock

func (l *ReentrantLock) Lock()

func (*ReentrantLock) Unlock

func (l *ReentrantLock) Unlock()

type SingleFlight

type SingleFlight interface {
	Do(key string, fn func() (any, error)) (any, error)
}

Jump to

Keyboard shortcuts

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