zbsync

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: LGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IncDec32

func IncDec32(int0 incdec[int32], int1_n ...any) (decfunc func())

IncDec32 用于引用计数 int0的类型必须随IncDec,可以是nil;int1_n可以是32和64混用 int1_n的最后1个或2个可以是接收+1或-1后的引用计数的函数,形如:func(...int32)

func IncDec64

func IncDec64(int0 incdec[int64], int1_n ...any) (decfunc func())

IncDec64 用于引用计数 int0的类型必须随IncDec,可以是nil;int1_n可以是32和64混用 int1_n的最后1个或2个可以是接收+1或-1后的引用计数的函数,形如:func(...int64)

Types

type AtomTotaliser

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

func (*AtomTotaliser) Add

func (this *AtomTotaliser) Add(id string, amount int32)

func (*AtomTotaliser) ResetAll

func (this *AtomTotaliser) ResetAll() (ids []string, amounts []int32)

type Int32

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

Int32 atomic.Int32,用于引用计数+1-1

func (*Int32) CompareAndSwap

func (this *Int32) CompareAndSwap(old, new int32) (swapped bool)

func (*Int32) Dec

func (this *Int32) Dec() int32

func (*Int32) Inc

func (this *Int32) Inc() int32

func (*Int32) Load

func (this *Int32) Load() int32

func (*Int32) Store

func (this *Int32) Store(val int32)

type Int64

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

Int64 atomic.Int64,用于引用计数+1-1

func (*Int64) CompareAndSwap

func (this *Int64) CompareAndSwap(old, new int64) (swapped bool)

func (*Int64) Dec

func (this *Int64) Dec() int64

func (*Int64) Inc

func (this *Int64) Inc() int64

func (*Int64) Load

func (this *Int64) Load() int64

func (*Int64) Store

func (this *Int64) Store(val int64)

type Mutex

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

---------------type Mutex struct------------------------------------------------------------------------- 标准互斥锁封装,不支持递归(嵌套)Lock

func (*Mutex) Lock

func (this *Mutex) Lock() (Unlock func())

func (*Mutex) LockFun

func (this *Mutex) LockFun(fun func())

type Mutex2

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

func (*Mutex2) Lock

func (this *Mutex2) Lock() (Unlock func())

type RWMutex

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

---------------type RWMutex struct------------------------------------------------------------------------- 标准读写锁封装,不支持递归(嵌套)读Lock、不支持递归(嵌套)写Lock

func (*RWMutex) Lock

func (this *RWMutex) Lock() (Unlock func())

func (*RWMutex) LockFun

func (this *RWMutex) LockFun(fun func())

func (*RWMutex) Locker

func (this *RWMutex) Locker() sync.Locker

func (*RWMutex) RLock

func (this *RWMutex) RLock() (RUnlock func())

func (*RWMutex) RLockFun

func (this *RWMutex) RLockFun(fun func())

type RWMutex2

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

---------------type RWMutex2 struct------------------------------------------------------------------------- 简单实现的读写锁2,支持递归读Lock、不支持递归写Lock

func (*RWMutex2) Lock

func (this *RWMutex2) Lock() (Unlock func())

func (*RWMutex2) LockFun

func (this *RWMutex2) LockFun(fun func())

func (*RWMutex2) RLock

func (this *RWMutex2) RLock() (RUnlock func())

func (*RWMutex2) RLockFun

func (this *RWMutex2) RLockFun(fun func())

func (*RWMutex2) TryLock

func (this *RWMutex2) TryLock() (Unlock func())

type RWMutex3

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

---------------type RWMutex3 struct------------------------------------------------------------------------- 完美(功能)实现的读写锁3,支持无限递归(嵌套)写和无限递归(嵌套)读Lock,被读嵌套的写在写解锁时候会原子的过度到读(不会被其他写打断)

func (*RWMutex3) Lock

func (this *RWMutex3) Lock() (Unlock func())

func (*RWMutex3) LockFun

func (this *RWMutex3) LockFun(fun func())

func (*RWMutex3) RLock

func (this *RWMutex3) RLock() (RUnlock func())

func (*RWMutex3) RLockFun

func (this *RWMutex3) RLockFun(fun func())

func (*RWMutex3) TryLock

func (this *RWMutex3) TryLock() (Unlock func())

func (*RWMutex3) TryRLock

func (this *RWMutex3) TryRLock() (RUnlock func())

type RWMutex4

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

RWMutex4 RWMutex3的复制品,实现写优先,代价较高,用于慢速环境,不推荐使用,尽量使用RWMutex3

func (*RWMutex4) Lock

func (this *RWMutex4) Lock() (Unlock func())

func (*RWMutex4) LockFun

func (this *RWMutex4) LockFun(fun func())

func (*RWMutex4) RLock

func (this *RWMutex4) RLock() (RUnlock func())

func (*RWMutex4) RLockFun

func (this *RWMutex4) RLockFun(fun func())

func (*RWMutex4) TryLock

func (this *RWMutex4) TryLock() (Unlock func())

func (*RWMutex4) TryRLock

func (this *RWMutex4) TryRLock() (RUnlock func())

Jump to

Keyboard shortcuts

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