mutexx

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HolderCount

func HolderCount(m *sync.Mutex) int

HolderCount 锁的持有者数量 0或者1

func IsLocked

func IsLocked(m *sync.Mutex) bool

IsLocked 锁是否被持有

func IsStarving

func IsStarving(m *sync.Mutex) bool

IsStarving 锁是否处于饥饿状态

func IsWoken

func IsWoken(m *sync.Mutex) bool

IsWoken 是否有等待者被唤醒

func TryLock

func TryLock(m *sync.Mutex) bool

TryLock 尝试获取锁

func WaiterCount

func WaiterCount(m *sync.Mutex) int

WaiterCount 锁的等待者数量

Types

type ChanMutex

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

func NewChanMutex

func NewChanMutex() *ChanMutex

func (*ChanMutex) IsLocked

func (m *ChanMutex) IsLocked() bool

func (*ChanMutex) Lock

func (m *ChanMutex) Lock()

func (*ChanMutex) LockContext

func (m *ChanMutex) LockContext(ctx context.Context) bool

func (*ChanMutex) TryLock

func (m *ChanMutex) TryLock() bool

func (*ChanMutex) Unlock

func (m *ChanMutex) Unlock()

type RecursiveMutex

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

RecursiveMutex 包装一个Mutex,实现可重入

func (*RecursiveMutex) Lock

func (m *RecursiveMutex) Lock()

func (*RecursiveMutex) Unlock

func (m *RecursiveMutex) Unlock()

type SpinMutex

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

func (*SpinMutex) Lock

func (m *SpinMutex) Lock()

func (*SpinMutex) Unlock

func (m *SpinMutex) Unlock()

type TokenRecursiveMutex

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

TokenRecursiveMutex Token方式的递归锁

func (*TokenRecursiveMutex) Lock

func (m *TokenRecursiveMutex) Lock(token int64)

Lock 请求锁,需要传入token

func (*TokenRecursiveMutex) Unlock

func (m *TokenRecursiveMutex) Unlock(token int64)

Unlock 释放锁

Jump to

Keyboard shortcuts

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