concurrency

package
v0.0.0-...-be256ff Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LockTypesCanBeParent

func LockTypesCanBeParent(parent, child LockType) bool

LockTypesCanBeParent returns if a parent with the given LockType can grant the given LockType to its child

func LockTypesCompatible

func LockTypesCompatible(l1, l2 LockType) bool

LockTypesCompatible returns if locks of type l1 and l2 can applied to a resource at the same time.

func LockTypesSubstitutable

func LockTypesSubstitutable(have, want LockType) bool

LockTypesSubstitutable returns if a lock with type 'have' can substitute a lock with type 'want'.

Types

type ChildSet

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

func NewTransactionRefCounter

func NewTransactionRefCounter() *ChildSet

func (*ChildSet) AddChild

func (t *ChildSet) AddChild(ptr *MultiLevelLock)

func (*ChildSet) AddReference

func (t *ChildSet) AddReference(txId TransactionId, childKey ResourceNamePart)

func (*ChildSet) ClearReferences

func (t *ChildSet) ClearReferences(txId TransactionId)

func (*ChildSet) RemoveChild

func (t *ChildSet) RemoveChild(childKey ResourceNamePart)

func (*ChildSet) RemoveReference

func (t *ChildSet) RemoveReference(txId TransactionId, childKey ResourceNamePart)

func (*ChildSet) String

func (t *ChildSet) String() string

func (*ChildSet) TransactionChildren

func (t *ChildSet) TransactionChildren(txId TransactionId) []*MultiLevelLock

func (*ChildSet) TransactionCount

func (t *ChildSet) TransactionCount(txId TransactionId) int

type DatabaseLock

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

func NewDatabaseLock

func NewDatabaseLock() *DatabaseLock

func (*DatabaseLock) EnsureLock

func (d *DatabaseLock) EnsureLock(txId TransactionId, resource ResourceName, lockType LockType) error

func (*DatabaseLock) Free

func (d *DatabaseLock) Free(txId TransactionId) error

func (*DatabaseLock) PrintAllLocks

func (d *DatabaseLock) PrintAllLocks()

type Lock

type Lock struct {
	Name        ResourceName
	Transaction TransactionId
	Type        LockType
}

type LockEntry

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

func NewLockEntry

func NewLockEntry(name ResourceName, txLockMap *TransactionLockMap) *LockEntry

func (*LockEntry) AddToQueue

func (l *LockEntry) AddToQueue(request lockRequest, front bool)

func (*LockEntry) LockCompatible

func (l *LockEntry) LockCompatible(lockType LockType, txId TransactionId) bool

func (*LockEntry) Release

func (l *LockEntry) Release(txId TransactionId)

func (*LockEntry) TransactionLockType

func (l *LockEntry) TransactionLockType(txId TransactionId) LockType

type LockList

type LockList []Lock

func (LockList) Contains

func (l LockList) Contains(lock Lock) bool

type LockManager

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

func (*LockManager) Acquire

func (l *LockManager) Acquire(txId TransactionId, name ResourceName, lockType LockType) error

func (*LockManager) AcquireThenRelease

func (l *LockManager) AcquireThenRelease(txId TransactionId, name ResourceName, lockType LockType, releases []ResourceName) error

func (*LockManager) LockType

func (l *LockManager) LockType(txId TransactionId, name ResourceName) LockType

func (*LockManager) Promote

func (l *LockManager) Promote(txId TransactionId, name ResourceName, newLockType LockType) error

func (*LockManager) Release

func (l *LockManager) Release(txId TransactionId, name ResourceName) error

func (*LockManager) ReleaseAll

func (l *LockManager) ReleaseAll(txId TransactionId) error

type LockType

type LockType uint8
const (
	NoLock  LockType = 0 // No lock held
	ISLock  LockType = 1 // Intention shared
	IXLock  LockType = 2 // Intention exclusive
	SLock   LockType = 3 // Shared
	SIXLock LockType = 4 // Shared intention exclusive
	XLock   LockType = 5 // Exclusive
)

func (LockType) CanBeChildOf

func (l LockType) CanBeChildOf(parent LockType) bool

func (LockType) CanBeParentOf

func (l LockType) CanBeParentOf(child LockType) bool

func (LockType) CanSubsitute

func (l LockType) CanSubsitute(other LockType) bool

func (LockType) Compatible

func (l LockType) Compatible(other LockType) bool

func (LockType) IsIntent

func (l LockType) IsIntent() bool

func (LockType) LockOfParent

func (l LockType) LockOfParent() LockType

func (LockType) String

func (l LockType) String() string

type MultiLevelLock

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

func NewMultiLevelLock

func NewMultiLevelLock(manager *LockManager, parent *MultiLevelLock, key ResourceNamePart) *MultiLevelLock

func (*MultiLevelLock) Acquire

func (m *MultiLevelLock) Acquire(txId TransactionId, lockType LockType) error

func (*MultiLevelLock) EffectiveLockType

func (m *MultiLevelLock) EffectiveLockType(txId TransactionId) LockType

func (*MultiLevelLock) Esclate

func (m *MultiLevelLock) Esclate(txId TransactionId) error

func (*MultiLevelLock) LockType

func (m *MultiLevelLock) LockType(txId TransactionId) LockType

func (*MultiLevelLock) PrintAllLocks

func (m *MultiLevelLock) PrintAllLocks()

func (*MultiLevelLock) Promote

func (m *MultiLevelLock) Promote(txId TransactionId, newLockType LockType) error

func (*MultiLevelLock) Release

func (m *MultiLevelLock) Release(txId TransactionId) error

type ResourceName

type ResourceName struct {
	Parts []ResourceNamePart
	// contains filtered or unexported fields
}

func NewCodeResourceName

func NewCodeResourceName(marketCode, code string) ResourceName

func NewMarketResourceName

func NewMarketResourceName(marketCode string) ResourceName

func NewResourceName

func NewResourceName(parts []ResourceNamePart) ResourceName

func NewSetResourceName

func NewSetResourceName(set page.CandleSet) ResourceName

func (ResourceName) CreateChild

func (r ResourceName) CreateChild(key ResourceNamePart) ResourceName

func (ResourceName) Hash

func (r ResourceName) Hash() uint64

func (ResourceName) LastPart

func (r ResourceName) LastPart() ResourceNamePart

func (ResourceName) String

func (r ResourceName) String() string

type ResourceNamePart

type ResourceNamePart struct {
	Value string
	// contains filtered or unexported fields
}

func NewResourceNamePart

func NewResourceNamePart(value string) ResourceNamePart

func (ResourceNamePart) Hash

func (r ResourceNamePart) Hash() uint64

func (ResourceNamePart) String

func (r ResourceNamePart) String() string

type TransactionId

type TransactionId uint64

type TransactionLockMap

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

func NewTransactionLockMap

func NewTransactionLockMap() TransactionLockMap

func (*TransactionLockMap) AddLock

func (m *TransactionLockMap) AddLock(txId TransactionId, name ResourceName, lockType LockType)

func (*TransactionLockMap) AllResources

func (m *TransactionLockMap) AllResources(txId TransactionId) []ResourceName

func (*TransactionLockMap) Contains

func (m *TransactionLockMap) Contains(lock Lock) bool

func (*TransactionLockMap) ContainsResource

func (m *TransactionLockMap) ContainsResource(txId TransactionId, name ResourceName) bool

func (*TransactionLockMap) DeleteResource

func (m *TransactionLockMap) DeleteResource(txId TransactionId, name ResourceName)

func (*TransactionLockMap) LockTypes

func (m *TransactionLockMap) LockTypes(txId TransactionId, name ResourceName) []LockType

Jump to

Keyboard shortcuts

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