-fully working betterC for windows
*replaced array[..] = array[ .. ] sclice copy with mempcy *added own std library (allocator, alloca, Mutex) *changed tamplates for collecting components for systems -fixed issue with multiple optional components registering for system
This commit is contained in:
parent
ed99807871
commit
41f1c6474b
14 changed files with 722 additions and 868 deletions
|
|
@ -1,9 +1,10 @@
|
|||
module ecs.block_allocator;
|
||||
|
||||
import ecs.manager;
|
||||
|
||||
import ecs.std;
|
||||
/*
|
||||
import std.experimental.allocator;
|
||||
import std.experimental.allocator.mallocator : AlignedMallocator, Mallocator;
|
||||
import std.experimental.allocator.mallocator : AlignedMallocator, Mallocator;*/
|
||||
|
||||
struct BlockAllocator//(uint block_size, uint blocks_in_allocation)
|
||||
{
|
||||
|
|
@ -37,13 +38,13 @@ struct BlockAllocator//(uint block_size, uint blocks_in_allocation)
|
|||
|
||||
private void allocBlock() nothrow @nogc
|
||||
{
|
||||
next_block = cast(void*) AlignedMallocator.instance.alignedAllocate(
|
||||
next_block = cast(void*) Mallocator.alignAlloc(
|
||||
block_size * blocks_in_allocation, block_size);
|
||||
|
||||
if(pointers is null)pointers = Mallocator.instance.make!BlockPointers;
|
||||
if(pointers is null)pointers = Mallocator.make!BlockPointers;
|
||||
if(pointers.numberof >= 32)
|
||||
{
|
||||
BlockPointers* new_pointers = Mallocator.instance.make!BlockPointers;
|
||||
BlockPointers* new_pointers = Mallocator.make!BlockPointers;
|
||||
new_pointers.next_pointers = pointers;
|
||||
pointers = new_pointers;
|
||||
}
|
||||
|
|
@ -65,10 +66,10 @@ struct BlockAllocator//(uint block_size, uint blocks_in_allocation)
|
|||
{
|
||||
foreach(i;0..pointers.numberof)
|
||||
{
|
||||
AlignedMallocator.instance.dispose(pointers.blocks[i]);
|
||||
Mallocator.alignDispose(pointers.blocks[i]);
|
||||
}
|
||||
BlockPointers* next_pointers = pointers.next_pointers;
|
||||
Mallocator.instance.dispose(pointers);
|
||||
Mallocator.dispose(pointers);
|
||||
pointers = next_pointers;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue