internal

package
v0.0.0-...-be15534 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 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 Node

type Node struct {

	// Called when all dependencies are resolved.
	TrySendToTxnCache func(id cacheID) bool
	// Set the id generator to get a random ID.
	RandCacheID func() cacheID
	// Set the callback that the node is notified.
	OnNotified func(callback func())
	// contains filtered or unexported fields
}

Node is a node in the dependency graph used in conflict detection.

func NewNode

func NewNode(sortedDedupKeysHash []uint64) (ret *Node)

NewNode creates a new node.

func (*Node) DependOn

func (n *Node) DependOn(dependencyNodes map[int64]*Node, noDependencyKeyCnt int)

DependOn implements interface internal.SlotNode.

func (*Node) Free

func (n *Node) Free()

Free implements interface internal.SlotNode. It must be called if a node is no longer used. We are using sync.Pool to lessen the burden of GC.

func (*Node) Hashes

func (n *Node) Hashes() []uint64

Hashes implements interface internal.SlotNode.

func (*Node) NodeID

func (n *Node) NodeID() int64

NodeID implements interface internal.SlotNode.

func (*Node) Remove

func (n *Node) Remove()

Remove implements interface internal.SlotNode.

type SlotNode

type SlotNode[T any] interface {
	// NodeID tells the node's ID.
	NodeID() int64
	// Hashs returns the sorted and deduped hashes of the node.
	Hashes() []uint64
	// Construct a dependency on `others`.
	DependOn(dependencyNodes map[int64]T, noDependencyKeyCnt int)
	// Remove the node itself and notify all dependers.
	Remove()
	// Free the node itself and remove it from the graph.
	Free()
}

SlotNode describes objects that can be compared for equality.

type Slots

type Slots[E SlotNode[E]] struct {
	// contains filtered or unexported fields
}

Slots implements slot-based conflict detection. It holds references to E, which can be used to build a DAG of dependency.

func NewSlots

func NewSlots[E SlotNode[E]](numSlots uint64) *Slots[E]

NewSlots creates a new Slots.

func (*Slots[E]) Add

func (s *Slots[E]) Add(elem E)

Add adds an elem to the slots and calls DependOn for elem.

func (*Slots[E]) Free

func (s *Slots[E]) Free(elem E)

Free removes an element from the Slots.

Jump to

Keyboard shortcuts

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