-changes in EntityAlocator
* renamed to BlockAllocator * now it's template with compile time assingable block_size and block_in_allocation variables -WIP Event management * probably working sendSelfEvent() * registerEvent() -added win_dll.d as Windows DLL require functionality
This commit is contained in:
parent
d0fcdba6cd
commit
4ad81fe116
6 changed files with 264 additions and 57 deletions
|
|
@ -1,34 +0,0 @@
|
|||
module ecs.entity_allocator;
|
||||
|
||||
import ecs.manager;
|
||||
|
||||
import std.experimental.allocator;
|
||||
import std.experimental.allocator.mallocator : AlignedMallocator, Mallocator;
|
||||
|
||||
struct EntityAllocator
|
||||
{
|
||||
void* next_block;
|
||||
|
||||
void* getBlock()
|
||||
{
|
||||
if (next_block is null)
|
||||
allocBlock();
|
||||
void* ret = next_block;
|
||||
next_block = *cast(void**) next_block;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void allocBlock()
|
||||
{
|
||||
next_block = cast(void*) AlignedMallocator.instance.alignedAllocate(
|
||||
EntityManager.page_size * EntityManager.pages_in_block, EntityManager.page_size);
|
||||
foreach (i; 0 .. EntityManager.pages_in_block - 1)
|
||||
{
|
||||
void** pointer = cast(void**)(next_block + i * EntityManager.page_size);
|
||||
*pointer = next_block + (i + 1) * EntityManager.page_size;
|
||||
}
|
||||
void** pointer = cast(void**)(
|
||||
next_block + (EntityManager.pages_in_block - 1) * EntityManager.page_size);
|
||||
*pointer = null;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue