mutex

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mutex

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

func NewMutex

func NewMutex(root *Root, name string, options ...Option) *Mutex

func (Mutex) Lock

func (m Mutex) Lock() error

func (Mutex) Unlock

func (m Mutex) Unlock() error

type Option

type Option interface {
	Apply(mutex *baseMutex)
}

func WithExpireDuration

func WithExpireDuration(dur time.Duration) Option

func WithWaitTimeout

func WithWaitTimeout(timeout time.Duration) Option

type OptionFunc

type OptionFunc func(mutex *baseMutex)

func (OptionFunc) Apply

func (f OptionFunc) Apply(mutex *baseMutex)

type RWMutex

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

func NewRWMutex

func NewRWMutex(r *Root, name string, options ...Option) *RWMutex

func (RWMutex) Lock

func (r RWMutex) Lock() error

func (RWMutex) RLock

func (r RWMutex) RLock() error

func (RWMutex) Unlock

func (r RWMutex) Unlock() error

type Root

type Root struct {
	Client *redis.Client
	UUID   string // 自定义用于区分不同客户端的唯一标识
}

Jump to

Keyboard shortcuts

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