Documentation ¶
Overview ¶
Package memory offers gogen templates for memory managemant, structs can help to compose structure that takes garbage collection into account it gets rid of pointers, or lowers the allocations
Index ¶
- type Capsule
- type QuickPool
- type Storage
- func (s *Storage) Allocate() (*T, int32)
- func (s *Storage) Clear()
- func (s *Storage) Count() int
- func (s *Storage) Item(id int32) *T
- func (s *Storage) Len() int
- func (s *Storage) Occupied() []int32
- func (s *Storage) Remove(id int32)
- func (s *Storage) SlowClear()
- func (s *Storage) Used(id int32) bool
- type T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Capsule ¶
type Capsule struct {
// contains filtered or unexported fields
}
Capsule is something like an optional type, it holds boolean about whether it contains value though it does not hold pointer
type QuickPool ¶
type QuickPool struct {
// contains filtered or unexported fields
}
QuickPool ... def( rules QuickPool<T> QuickPool is template that can store interface referenced objects on one place reducing allocation, if you are creating lot of date stored behind interface that has very short livetime QuickPool can be nice optimization
func (*QuickPool) Item ¶
Item returns pointer to pooling struct that is free, if no free struct is present new one is allocated
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage ... def( rules Storage<T, int32> dep Capsule<T, Capsule> Storage generates IDs witch makes no need to use hashing, only drawback is that you cannot choose the id, it will be assigned like a pointer, but without putting presure no gc, brilliant storage for components. Its highly unlikely you will run out of ids as they are reused
func (*Storage) Allocate ¶
Allocate allocates an value and returns id and pointer to it. Note that allocate does not always allocate at all and just reuses freed space, returned pointer also does not point to zero value and you have to overwrite all properties to get expected behavior
func (*Storage) Item ¶
Item returns pointer to value under the "id", accessing random id can result in random value that can be considered unoccupied
method panics if id is not occupied
func (*Storage) Occupied ¶
Occupied return all occupied ids in storage, this method panics if Storage is outdated See Update method.
func (*Storage) Remove ¶
Remove removes a value and frees memory for something else
panic if there is nothing to free