latch

package
v2.0.8+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Latch

type Latch struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Latch stores a key's waiting transactions information.

type Latches

type Latches struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Latches which are used for concurrency control. Each latch is indexed by a slot's ID, hence the term latch and slot are used in interchangeable, but conceptually a latch is a queue, and a slot is an index to the queue

func NewLatches

func NewLatches(size int) *Latches

NewLatches create a Latches with fixed length, the size will be rounded up to the power of 2.

func (*Latches) Acquire

func (latches *Latches) Acquire(lock *Lock) (success, stale bool)

Acquire tries to acquire the lock for a transaction. It returns with stale = true when the transaction is stale( when the lock.startTS is smaller than any key's last commitTS).

func (*Latches) GenLock

func (latches *Latches) GenLock(startTS uint64, keys [][]byte) Lock

GenLock generates Lock for the transaction with startTS and keys.

func (*Latches) Release

func (latches *Latches) Release(lock *Lock, commitTS uint64) (wakeupList []uint64)

Release releases all latches owned by the `lock` and returns the wakeup list. Preconditions: the caller must ensure the transaction is at the front of the latches.

type Lock

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

Lock is the locks' information required for a transaction.

func NewLock

func NewLock(startTS uint64, requiredSlots []int) Lock

NewLock creates a new lock.

Jump to

Keyboard shortcuts

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