Documentation ¶
Index ¶
- Constants
- type EIndex
- type EjectionMode
- type Pool
- func (p *Pool) Add(entityId flow.Identifier, entity flow.Entity, owner uint64) (entityIndex EIndex, slotAvailable bool, ejectedEntity flow.Entity)
- func (p Pool) All() []PoolEntity
- func (p Pool) Get(entityIndex EIndex) (flow.Identifier, flow.Entity, uint64)
- func (p Pool) Head() (flow.Entity, bool)
- func (p *Pool) Remove(sliceIndex EIndex) flow.Entity
- func (p Pool) Size() uint32
- type PoolEntity
Constants ¶
View Source
const ( RandomEjection = EjectionMode("random-ejection") LRUEjection = EjectionMode("lru-ejection") NoEjection = EjectionMode("no-ejection") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EjectionMode ¶
type EjectionMode string
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func NewHeroPool ¶
func NewHeroPool(sizeLimit uint32, ejectionMode EjectionMode) *Pool
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) Head ¶ added in v0.28.0
Head returns the head of used items. Assuming no ejection happened and pool never goes beyond limit, Head returns the first inserted element.
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
Click to show internal directories.
Click to hide internal directories.