syncutils

package
v0.0.0-...-25ef478 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0, BSD-2-Clause Imports: 3 Imported by: 51

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KRWMutex

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

func NewKRWMutex

func NewKRWMutex() *KRWMutex

func (*KRWMutex) Free

func (kwrMutex *KRWMutex) Free(key interface{})

func (*KRWMutex) Register

func (krwMutex *KRWMutex) Register(key interface{}) (result *RWMutex)

type LockableEntity

type LockableEntity interface {
	// Locks returns the locks that the entity needs to lock.
	Locks() (locks []interface{})
}

LockableEntity is an interface that allows to lock (and unlock) entities that are generating complex locks.

type MultiMutex

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

MultiMutex is a mutex that allows to lock multiple entities exclusively. Entities are represented by interface{} identifiers and can be presented in arbitrary order. Goroutine 1 Goroutine 2 Goroutine 3

Lock(a,c)           		-          Lock(c,b) <- blocking
     work            Lock(b)   	        wait

Unlock(a,c) work wait

  • Unlock(b) wait
  • - Lock(c,b) <- successful

func NewMultiMutex

func NewMultiMutex() *MultiMutex

NewMultiMutex creates a new MultiMutex.

func (*MultiMutex) Lock

func (m *MultiMutex) Lock(ids ...interface{})

Lock blocks until all locks given by ids can be acquired atomically.

func (*MultiMutex) LockEntity

func (m *MultiMutex) LockEntity(entity LockableEntity)

LockEntity locks all locks that are required for the given LockableEntity.

func (*MultiMutex) Unlock

func (m *MultiMutex) Unlock(ids ...interface{})

Unlock releases the locks of ids.

func (*MultiMutex) UnlockEntity

func (m *MultiMutex) UnlockEntity(entity LockableEntity)

UnlockEntity unlocks all locks that are required for the given LockableEntity.

type MultiMutexLockBuilder

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

func (*MultiMutexLockBuilder) AddLock

func (lockBuilder *MultiMutexLockBuilder) AddLock(identifier interface{}) *MultiMutexLockBuilder

func (*MultiMutexLockBuilder) Build

func (lockBuilder *MultiMutexLockBuilder) Build() []interface{}

type Mutex

type Mutex = sync.Mutex

type RWMultiMutex

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

func (*RWMultiMutex) Lock

func (mutex *RWMultiMutex) Lock(identifiers ...interface{})

func (*RWMultiMutex) RLock

func (mutex *RWMultiMutex) RLock(identifiers ...interface{})

func (*RWMultiMutex) RUnlock

func (mutex *RWMultiMutex) RUnlock(identifiers ...interface{})

func (*RWMultiMutex) Unlock

func (mutex *RWMultiMutex) Unlock(identifiers ...interface{})

type RWMutex

type RWMutex = sync.RWMutex

Jump to

Keyboard shortcuts

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