queue

package
v0.29.16-skip-indicies... Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: AGPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blockify

type Blockify interface {
	flow.Entity
	Height() uint64
	ParentID() flow.Identifier
}

Blockify becuase Blocker seems a bit off. Make items behave like a block, so it can be queued

type HeroQueue added in v0.29.0

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

HeroQueue implements a HeroCache-based in-memory queue. HeroCache is a key-value cache with zero heap allocation and optimized Garbage Collection.

func NewHeroQueue added in v0.29.0

func NewHeroQueue(sizeLimit uint32, logger zerolog.Logger, collector module.HeroCacheMetrics) *HeroQueue

func (*HeroQueue) Pop added in v0.29.0

func (c *HeroQueue) Pop() (flow.Entity, bool)

Pop removes and returns the head of queue, and updates the head to the next element. Boolean return value determines whether pop is successful, i.e., popping an empty queue returns false.

func (*HeroQueue) Push added in v0.29.0

func (c *HeroQueue) Push(entity flow.Entity) bool

Push stores the entity into the queue. Boolean returned variable determines whether push was successful, i.e., push may be dropped if queue is full or already exists.

func (*HeroQueue) Size added in v0.29.0

func (c *HeroQueue) Size() uint

type HeroStore added in v0.29.0

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

HeroStore is a FIFO (first-in-first-out) size-bound queue for maintaining engine.Message types. It is based on HeroQueue.

func NewHeroStore added in v0.29.0

func NewHeroStore(sizeLimit uint32, logger zerolog.Logger, collector module.HeroCacheMetrics) *HeroStore

func (*HeroStore) Get added in v0.29.0

func (c *HeroStore) Get() (*engine.Message, bool)

Get pops the queue, i.e., it returns the head of queue, and updates the head to the next element. Boolean return value determines whether pop is successful, i.e., popping an empty queue returns false.

func (*HeroStore) Put added in v0.29.0

func (c *HeroStore) Put(message *engine.Message) bool

Put enqueues the message into the message store.

Boolean returned variable determines whether enqueuing was successful, i.e., put may be dropped if queue is full or already exists.

type Node

type Node struct {
	Item     Blockify
	Children []*Node
}

type Queue

type Queue struct {
	Head    *Node
	Highest *Node
	Nodes   map[flow.Identifier]*Node
}

Queue is a fork-aware queue/tree of blocks for use in execution Node, where parallel forks can be processed simultaneously. For fast lookup which is predicted to be common case all nodes are kept as one queue, which is expected to split into separate queues once a fork (multiple children) is reached. Note that this is not a thread-safe structure and external synchronisation is required to use in concurrent environment

func NewQueue

func NewQueue(blockify Blockify) *Queue

func (*Queue) Checksum

func (q *Queue) Checksum() flow.Identifier

func (*Queue) Dismount

func (q *Queue) Dismount() (Blockify, []*Queue)

Dismount removes the head element, returns it and it's children as new queues

func (*Queue) Height

func (q *Queue) Height() uint64

Returns difference between lowest and highest element in the queue Formally, the Queue stores a tree. The height of the tree is the number of edges on the longest downward path between the root and any leaf.

func (*Queue) ID

func (q *Queue) ID() flow.Identifier

func (*Queue) Size

func (q *Queue) Size() int

Size returns number of elements in the queue

func (*Queue) TryAdd

func (q *Queue) TryAdd(element Blockify) (stored bool, new bool)

TryAdd tries to add a new element to the queue. A element can only be added if the parent exists in the queue. TryAdd(elmt) is an idempotent operation for the same elmt, i.e. after the first, subsequent additions of the same elements are NoOps. Returns: stored = True if and only if _after_ the operation, the element is stored in the queue. This is the case if (a) element was newly added to the queue or (b) element was already stored in the queue _before_ the call. new = Indicates if element was new to the queue, when `stored` was true. It lets distinguish (a) and (b) cases. Adding an element fails with return value `false` for `stored` in the following cases:

  • element.ParentID() is _not_ stored in the queue
  • element's height is _unequal to_ its parent's height + 1

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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