Documentation ¶
Overview ¶
Package sync 提供一些额外的、非常规的 sync 功能
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Map ¶
type Map[K comparable, V comparable] interface { CompareAndDelete(key K, old V) (deleted bool) CompareAndSwap(key K, old, new V) bool Delete(key K) Load(key K) (value V, ok bool) LoadAndDelete(key K) (value V, loaded bool) LoadOrStore(key K, value V) (actual V, loaded bool) Range(f func(key K, value V) bool) Store(key K, value V) Swap(key K, value V) (previous V, loaded bool) }
Map 是 sync.Map 的封装, 但是暴露的参数类型是泛型
func NewMap ¶
func NewMap[K comparable, V comparable]() Map[K, V]
type Option ¶
type Option func(opt *option)
Option 表示额外参数, 只能通过本 package 调用
func WithReentrantNotification ¶
func WithReentrantNotification(f ReentrantNotifyFunc) Option
WithReentrantNotification 指定发生重入时, 调用回调
func WithRetryInterval ¶
WithRetryInterval 指定重试的时间间隔
type ReentrantLock ¶
type ReentrantLock struct {
// contains filtered or unexported fields
}
ReentrantLock 表示一个可重入锁
Ref: [Go语言如何实现可重入锁?](https://segmentfault.com/a/1190000040092635)
func NewReentrantLock ¶
func NewReentrantLock(opts ...Option) *ReentrantLock
NewReentrantLock 返回一个新的可重入锁
type ReentrantNotifyFunc ¶
type ReentrantNotifyFunc func(goroutineID int64)
ReentrantNotifyFunc 表示发生重入时的通知函数类型
Click to show internal directories.
Click to hide internal directories.