heropool

package
v0.33.20-find-inconsis... Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RandomEjection = EjectionMode("random-ejection")
	LRUEjection    = EjectionMode("lru-ejection")
	NoEjection     = EjectionMode("no-ejection")
)

Variables

This section is empty.

Functions

func NewStates added in v0.32.0

func NewStates(numberOfStates int) []state

NewStates constructs an array of a doubly linked-lists.

Types

type EIndex

type EIndex uint32

EIndex is data type representing an entity index in Pool.

const InvalidIndex EIndex = math.MaxUint32

InvalidIndex is used when a link doesnt point anywhere, in other words it is an equivalent of a nil address.

type EjectionMode

type EjectionMode string

type Pool

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

func NewHeroPool

func NewHeroPool(sizeLimit uint32, ejectionMode EjectionMode, logger zerolog.Logger) *Pool

NewHeroPool returns a pointer to a new hero pool constructed based on a provided EjectionMode, logger and a provided fixed size.

func (*Pool) Add

func (p *Pool) Add(entityId flow.Identifier, entity flow.Entity, owner uint64) (
	entityIndex EIndex, slotAvailable bool, ejectedEntity flow.Entity)

Add writes given entity into a poolEntity on the underlying entities linked-list.

The boolean return value (slotAvailable) says whether pool has an available slot. Pool goes out of available slots if it is full and no ejection is set.

If the pool has no available slots and an ejection is set, ejection occurs when adding a new entity. If an ejection occurred, ejectedEntity holds the ejected entity.

func (Pool) All

func (p Pool) All() []PoolEntity

All returns all stored entities in this pool.

func (*Pool) Get

func (p *Pool) Get(entityIndex EIndex) (flow.Identifier, flow.Entity, uint64)

Get returns entity corresponding to the entity index from the underlying list.

func (Pool) Head added in v0.28.0

func (p Pool) Head() (flow.Entity, bool)

Head returns the head of used items. Assuming no ejection happened and pool never goes beyond limit, Head returns the first inserted element.

func (*Pool) Remove added in v0.27.0

func (p *Pool) Remove(sliceIndex EIndex) flow.Entity

Remove removes entity corresponding to given getSliceIndex from the list.

func (Pool) Size

func (p Pool) Size() uint32

Size returns total number of entities that this list maintains.

type PoolEntity

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

func (PoolEntity) Entity

func (p PoolEntity) Entity() flow.Entity

func (PoolEntity) Id

func (p PoolEntity) Id() flow.Identifier

type StateIndex added in v0.32.0

type StateIndex uint

StateIndex is a type of a state of a placeholder in a pool.

Jump to

Keyboard shortcuts

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