latch

package
v2.1.0-beta+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

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 uint) *Latches

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

type LatchesScheduler

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

LatchesScheduler is used to schedule latches for transactions.

func NewScheduler

func NewScheduler(size uint) *LatchesScheduler

NewScheduler create the LatchesScheduler.

func (*LatchesScheduler) Close

func (scheduler *LatchesScheduler) Close()

Close closes LatchesScheduler.

func (*LatchesScheduler) Lock

func (scheduler *LatchesScheduler) Lock(startTS uint64, keys [][]byte) *Lock

Lock acquire the lock for transaction with startTS and keys. The caller goroutine would be blocked if the lock can't be obtained now. When this function returns, the lock state would be either success or stale(call lock.IsStale)

func (*LatchesScheduler) RefreshCommitTS

func (scheduler *LatchesScheduler) RefreshCommitTS(keys [][]byte, commitTS uint64)

RefreshCommitTS refreshes commitTS for keys. It could be used for the transaction not retryable, which would do 2PC directly and wouldn't get a lock.

func (*LatchesScheduler) UnLock

func (scheduler *LatchesScheduler) UnLock(lock *Lock)

UnLock unlocks a lock.

type Lock

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

Lock is the locks' information required for a transaction.

func (*Lock) IsStale

func (l *Lock) IsStale() bool

IsStale returns whether the status is stale.

func (*Lock) SetCommitTS

func (l *Lock) SetCommitTS(commitTS uint64)

SetCommitTS sets the lock's commitTS.

Jump to

Keyboard shortcuts

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