-almost every funtion is marked as @nogc and nothrow (only problem with HashMap)
This commit is contained in:
parent
fef55bd790
commit
204ce9dc79
10 changed files with 74 additions and 72 deletions
|
|
@ -12,7 +12,7 @@ struct BlockAllocator//(uint block_size, uint blocks_in_allocation)
|
||||||
|
|
||||||
void* next_block = null;
|
void* next_block = null;
|
||||||
|
|
||||||
void* getBlock()
|
void* getBlock() nothrow @nogc
|
||||||
{
|
{
|
||||||
if (next_block is null)
|
if (next_block is null)
|
||||||
allocBlock();
|
allocBlock();
|
||||||
|
|
@ -21,13 +21,13 @@ struct BlockAllocator//(uint block_size, uint blocks_in_allocation)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void freeBlock(void* block)
|
void freeBlock(void* block) nothrow @nogc
|
||||||
{
|
{
|
||||||
*cast(void**)block = next_block;
|
*cast(void**)block = next_block;
|
||||||
next_block = block;
|
next_block = block;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void allocBlock()
|
private void allocBlock() nothrow @nogc
|
||||||
{
|
{
|
||||||
next_block = cast(void*) AlignedMallocator.instance.alignedAllocate(
|
next_block = cast(void*) AlignedMallocator.instance.alignedAllocate(
|
||||||
block_size * blocks_in_allocation, block_size);
|
block_size * blocks_in_allocation, block_size);
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ static struct ECS
|
||||||
__gshared ushort system_id;
|
__gshared ushort system_id;
|
||||||
EntityManager.Job[] _ecs_jobs;
|
EntityManager.Job[] _ecs_jobs;
|
||||||
|
|
||||||
void __ecsInitialize()
|
void __ecsInitialize() nothrow @nogc
|
||||||
{
|
{
|
||||||
import std.experimental.allocator.mallocator;
|
import std.experimental.allocator.mallocator;
|
||||||
import std.experimental.allocator;
|
import std.experimental.allocator;
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ struct Entity
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Update pointer to it in IDManager
|
*Update pointer to it in IDManager
|
||||||
*/
|
*/
|
||||||
void updateID()
|
void updateID() nothrow @nogc
|
||||||
{
|
{
|
||||||
EntityManager.instance.id_manager.update(this);
|
EntityManager.instance.id_manager.update(this);
|
||||||
}
|
}
|
||||||
|
|
@ -60,7 +60,7 @@ export struct EntityTemplate
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Get specified component. If component doesn't exist function return null.
|
*Get specified component. If component doesn't exist function return null.
|
||||||
*/
|
*/
|
||||||
T* getComponent(T)()
|
T* getComponent(T)() nothrow @nogc
|
||||||
{
|
{
|
||||||
if(T.component_id >= info.tmpl_deltas.length)return null;
|
if(T.component_id >= info.tmpl_deltas.length)return null;
|
||||||
return cast(T*)(entity_data.ptr + info.tmpl_deltas[T.component_id]);
|
return cast(T*)(entity_data.ptr + info.tmpl_deltas[T.component_id]);
|
||||||
|
|
|
||||||
|
|
@ -70,13 +70,13 @@ struct EventManager
|
||||||
block.index = cast(ushort)(aligned_index + Ev.sizeof);
|
block.index = cast(ushort)(aligned_index + Ev.sizeof);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
void initialize(EntityManager m)
|
void initialize(EntityManager m) nothrow @nogc
|
||||||
{
|
{
|
||||||
allocator = BlockAllocator(events_block_size, events_blocks_in_allocation);
|
allocator = BlockAllocator(events_block_size, events_blocks_in_allocation);
|
||||||
manager = m;
|
manager = m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendEvent(Ev)(EntityID id, Ev event, uint thread_id = 0)
|
void sendEvent(Ev)(EntityID id, Ev event, uint thread_id = 0) nothrow @nogc
|
||||||
{
|
{
|
||||||
uint block_id = current_index+thread_id;
|
uint block_id = current_index+thread_id;
|
||||||
|
|
||||||
|
|
@ -110,7 +110,7 @@ struct EventManager
|
||||||
block.count++;
|
block.count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swapCurrent()
|
void swapCurrent() nothrow @nogc
|
||||||
{
|
{
|
||||||
uint threads_count = cast(uint)manager.threads.length;
|
uint threads_count = cast(uint)manager.threads.length;
|
||||||
if(current_index == 0)current_index = threads_count;
|
if(current_index == 0)current_index = threads_count;
|
||||||
|
|
@ -136,7 +136,7 @@ struct EventManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearEvents()
|
void clearEvents() nothrow @nogc
|
||||||
{
|
{
|
||||||
uint threads_count = cast(uint)manager.threads.length;
|
uint threads_count = cast(uint)manager.threads.length;
|
||||||
foreach(ref event;events)
|
foreach(ref event;events)
|
||||||
|
|
@ -173,7 +173,7 @@ struct EventManager
|
||||||
process_events.current_block = null;*/
|
process_events.current_block = null;*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void allocateData(uint threads_count)
|
void allocateData(uint threads_count) nothrow @nogc
|
||||||
{
|
{
|
||||||
if(events)
|
if(events)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ private enum HASH_EMPTY = 0;
|
||||||
private enum HASH_DELETED = 0x1;
|
private enum HASH_DELETED = 0x1;
|
||||||
private enum HASH_FILLED_MARK = ulong(1) << 8 * ulong.sizeof - 1;
|
private enum HASH_FILLED_MARK = ulong(1) << 8 * ulong.sizeof - 1;
|
||||||
|
|
||||||
export ulong defaultHashFunc(T)(auto ref T t) {
|
export ulong defaultHashFunc(T)(auto ref T t) nothrow @nogc {
|
||||||
static if (isIntegral!(T)) {
|
static if (isIntegral!(T)) {
|
||||||
return hashInt(t);
|
return hashInt(t);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ struct IDManager
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Get new ID.
|
*Get new ID.
|
||||||
*/
|
*/
|
||||||
pragma(inline, false) EntityID getNewID()
|
pragma(inline, false) EntityID getNewID() nothrow @nogc
|
||||||
{
|
{
|
||||||
//uint current = m_next_id;
|
//uint current = m_next_id;
|
||||||
//uint next;// = m_ids_array[m_next_id].next_id;
|
//uint next;// = m_ids_array[m_next_id].next_id;
|
||||||
|
|
@ -35,13 +35,13 @@ begin:
|
||||||
uint block_id = local_id >> 16;
|
uint block_id = local_id >> 16;
|
||||||
if (block_id >= m_blocks_count)
|
if (block_id >= m_blocks_count)
|
||||||
{
|
{
|
||||||
add_mutex.lock();
|
add_mutex.lock_nothrow();
|
||||||
if(block_id >= m_blocks_count)
|
if(block_id >= m_blocks_count)
|
||||||
{
|
{
|
||||||
m_blocks[m_blocks_count].alloc();
|
m_blocks[m_blocks_count].alloc();
|
||||||
m_blocks_count++;
|
m_blocks_count++;
|
||||||
}
|
}
|
||||||
add_mutex.unlock();
|
add_mutex.unlock_nothrow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -79,7 +79,7 @@ begin:
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Release ID.
|
*Release ID.
|
||||||
*/
|
*/
|
||||||
void releaseID(EntityID id)
|
void releaseID(EntityID id) nothrow @nogc
|
||||||
{
|
{
|
||||||
Data* data = &m_ids_array[id.id];
|
Data* data = &m_ids_array[id.id];
|
||||||
if (data.counter != id.counter)
|
if (data.counter != id.counter)
|
||||||
|
|
@ -96,7 +96,7 @@ begin:
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Update pointer to entity. The purpose of this function is to ensure that pointer to entity is always correct.
|
*Update pointer to entity. The purpose of this function is to ensure that pointer to entity is always correct.
|
||||||
*/
|
*/
|
||||||
void update(ref Entity entity)
|
void update(ref Entity entity) nothrow @nogc
|
||||||
{
|
{
|
||||||
if (entity.id.id >= cast(uint) m_ids_array.length)
|
if (entity.id.id >= cast(uint) m_ids_array.length)
|
||||||
{
|
{
|
||||||
|
|
@ -112,7 +112,7 @@ begin:
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Returns pointer to entity.
|
*Returns pointer to entity.
|
||||||
*/
|
*/
|
||||||
export Entity* getEntityPointer(EntityID id)
|
export Entity* getEntityPointer(EntityID id) nothrow @nogc
|
||||||
{
|
{
|
||||||
if (id.id >= m_ids_array.length)
|
if (id.id >= m_ids_array.length)
|
||||||
{
|
{
|
||||||
|
|
@ -137,13 +137,13 @@ begin:
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Check if entity with specified ID exist.
|
*Check if entity with specified ID exist.
|
||||||
*/
|
*/
|
||||||
export bool isExist(EntityID id)
|
export bool isExist(EntityID id) nothrow @nogc
|
||||||
{
|
{
|
||||||
Data* data = &m_ids_array[id.id];
|
Data* data = &m_ids_array[id.id];
|
||||||
return data.counter == id.counter;
|
return data.counter == id.counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void initialize()
|
void initialize() nothrow @nogc
|
||||||
{
|
{
|
||||||
m_ids_array = Mallocator.instance.makeArray!Data(65536);
|
m_ids_array = Mallocator.instance.makeArray!Data(65536);
|
||||||
m_free_stack = Mallocator.instance.makeArray!uint(65536);
|
m_free_stack = Mallocator.instance.makeArray!uint(65536);
|
||||||
|
|
@ -154,7 +154,7 @@ begin:
|
||||||
add_mutex = Mallocator.instance.make!Mutex();
|
add_mutex = Mallocator.instance.make!Mutex();
|
||||||
}
|
}
|
||||||
|
|
||||||
void optimize()
|
void optimize() nothrow @nogc
|
||||||
{
|
{
|
||||||
if(m_stack_top < -1)m_stack_top = -1;
|
if(m_stack_top < -1)m_stack_top = -1;
|
||||||
if(m_last_id > m_ids_array.length)
|
if(m_last_id > m_ids_array.length)
|
||||||
|
|
@ -183,13 +183,13 @@ begin:
|
||||||
|
|
||||||
private static struct Block
|
private static struct Block
|
||||||
{
|
{
|
||||||
void alloc()
|
void alloc() nothrow @nogc
|
||||||
{
|
{
|
||||||
assert(data is null);
|
assert(data is null);
|
||||||
data = Mallocator.instance.makeArray!Data(65536);
|
data = Mallocator.instance.makeArray!Data(65536);
|
||||||
}
|
}
|
||||||
|
|
||||||
void free()
|
void free() nothrow @nogc
|
||||||
{
|
{
|
||||||
assert(data !is null);
|
assert(data !is null);
|
||||||
Mallocator.instance.dispose(data);
|
Mallocator.instance.dispose(data);
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ class EntityManager
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Begin registering process. Every register function should be called between beginRegister() and endRegister().
|
*Begin registering process. Every register function should be called between beginRegister() and endRegister().
|
||||||
*/
|
*/
|
||||||
void beginRegister()
|
void beginRegister() nothrow @nogc
|
||||||
{
|
{
|
||||||
assert(!register_state, "beginRegister() can't be called twice before endRegister();");
|
assert(!register_state, "beginRegister() can't be called twice before endRegister();");
|
||||||
register_state = true;
|
register_state = true;
|
||||||
|
|
@ -730,12 +730,12 @@ class EntityManager
|
||||||
Sys.system_id = system.id;
|
Sys.system_id = system.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
System* getSystem(ushort id)
|
System* getSystem(ushort id) nothrow @nogc
|
||||||
{
|
{
|
||||||
return &systems[id];
|
return &systems[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
Sys* getSystem(Sys)()
|
Sys* getSystem(Sys)() nothrow @nogc
|
||||||
{
|
{
|
||||||
return cast(Sys*) systems[Sys.system_id].m_system_pointer;
|
return cast(Sys*) systems[Sys.system_id].m_system_pointer;
|
||||||
}
|
}
|
||||||
|
|
@ -765,9 +765,10 @@ class EntityManager
|
||||||
&& is(ReturnType!(Comp.onDestroy) == void)
|
&& is(ReturnType!(Comp.onDestroy) == void)
|
||||||
&& Parameters!(Comp.onDestroy).length == 0)
|
&& Parameters!(Comp.onDestroy).length == 0)
|
||||||
{
|
{
|
||||||
static void callDestroy(void* pointer)
|
static void callDestroy(void* pointer) nothrow @nogc
|
||||||
|
|
||||||
{
|
{
|
||||||
(cast(Comp*) pointer).onDestroy();
|
(cast(void delegate() nothrow @nogc)&(cast(Comp*) pointer).onDestroy)();
|
||||||
}
|
}
|
||||||
|
|
||||||
info.destroy_callback = &callDestroy;
|
info.destroy_callback = &callDestroy;
|
||||||
|
|
@ -832,7 +833,7 @@ class EntityManager
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Same as "void update(int pass = 0)" but use pass name instead of id.
|
*Same as "void update(int pass = 0)" but use pass name instead of id.
|
||||||
*/
|
*/
|
||||||
void update(const(char)[] pass_name)
|
void update(const(char)[] pass_name) nothrow @nogc
|
||||||
{
|
{
|
||||||
ushort pass = passes_map.get(pass_name, ushort.max);
|
ushort pass = passes_map.get(pass_name, ushort.max);
|
||||||
assert(pass != ushort.max);
|
assert(pass != ushort.max);
|
||||||
|
|
@ -842,7 +843,7 @@ class EntityManager
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Update systems. Should be called only between begin() and end().
|
*Update systems. Should be called only between begin() and end().
|
||||||
*/
|
*/
|
||||||
export void update(ushort pass = 0)
|
export void update(ushort pass = 0) nothrow @nogc
|
||||||
{
|
{
|
||||||
assert(!register_state);
|
assert(!register_state);
|
||||||
assert(pass < passes.length);
|
assert(pass < passes.length);
|
||||||
|
|
@ -863,14 +864,14 @@ class EntityManager
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Same as "void updateMT(int pass = 0)" but use pass name instead of id.
|
*Same as "void updateMT(int pass = 0)" but use pass name instead of id.
|
||||||
*/
|
*/
|
||||||
void updateMT(const(char)[] pass_name)
|
void updateMT(const(char)[] pass_name) nothrow @nogc
|
||||||
{
|
{
|
||||||
ushort pass = passes_map.get(pass_name, ushort.max);
|
ushort pass = passes_map.get(pass_name, ushort.max);
|
||||||
assert(pass != ushort.max);
|
assert(pass != ushort.max);
|
||||||
updateMT(pass);
|
updateMT(pass);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateMT(ushort pass = 0)
|
void updateMT(ushort pass = 0) nothrow @nogc
|
||||||
{
|
{
|
||||||
assert(!register_state);
|
assert(!register_state);
|
||||||
assert(pass < passes.length);
|
assert(pass < passes.length);
|
||||||
|
|
@ -994,22 +995,22 @@ class EntityManager
|
||||||
nextJob();
|
nextJob();
|
||||||
|
|
||||||
caller.job_group.jobs = sys.jobs[0 .. job_id];
|
caller.job_group.jobs = sys.jobs[0 .. job_id];
|
||||||
m_dispatch_jobs(caller.job_group); //sys.jobs[0 .. job_id]);
|
(cast(void delegate(JobGroup) nothrow @nogc)m_dispatch_jobs)(caller.job_group); //sys.jobs[0 .. job_id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setJobDispachFunc(void delegate(JobGroup) func)
|
void setJobDispachFunc(void delegate(JobGroup) func) nothrow @nogc
|
||||||
{
|
{
|
||||||
m_dispatch_jobs = func;
|
m_dispatch_jobs = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void alignNum(ref ushort num, ushort alignment)
|
static void alignNum(ref ushort num, ushort alignment) nothrow @nogc
|
||||||
{
|
{
|
||||||
num = cast(ushort)((num + alignment - 1) & (-cast(int) alignment)); //num += alignment - (num & (alignment - 1));
|
num = cast(ushort)((num + alignment - 1) & (-cast(int) alignment)); //num += alignment - (num & (alignment - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
extern (C) static int compareUShorts(const void* a, const void* b)
|
extern (C) static int compareUShorts(const void* a, const void* b) nothrow @nogc
|
||||||
{
|
{
|
||||||
ushort _a = *cast(ushort*) a;
|
ushort _a = *cast(ushort*) a;
|
||||||
ushort _b = *cast(ushort*) b;
|
ushort _b = *cast(ushort*) b;
|
||||||
|
|
@ -1132,7 +1133,7 @@ class EntityManager
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
export void addSystemCaller(ref EntityInfo entity, uint system_id)
|
export void addSystemCaller(ref EntityInfo entity, uint system_id) nothrow @nogc
|
||||||
{
|
{
|
||||||
System* system = &systems[system_id];
|
System* system = &systems[system_id];
|
||||||
|
|
||||||
|
|
@ -1176,7 +1177,7 @@ class EntityManager
|
||||||
*params:
|
*params:
|
||||||
*id = ID of entity
|
*id = ID of entity
|
||||||
*/
|
*/
|
||||||
export Entity* getEntity(EntityID id)
|
export Entity* getEntity(EntityID id) nothrow @nogc
|
||||||
{
|
{
|
||||||
return cast(Entity*) id_manager.getEntityPointer(id);
|
return cast(Entity*) id_manager.getEntityPointer(id);
|
||||||
}
|
}
|
||||||
|
|
@ -1188,7 +1189,7 @@ class EntityManager
|
||||||
*entity_id = ID of entity
|
*entity_id = ID of entity
|
||||||
*del_ids = array of components IDs
|
*del_ids = array of components IDs
|
||||||
*/
|
*/
|
||||||
export void removeComponents(EntityID entity_id, ushort[] del_ids)
|
export void removeComponents(EntityID entity_id, ushort[] del_ids) nothrow @nogc
|
||||||
{
|
{
|
||||||
ThreadData* data = &threads[thread_id];
|
ThreadData* data = &threads[thread_id];
|
||||||
uint num = cast(uint) del_ids.length;
|
uint num = cast(uint) del_ids.length;
|
||||||
|
|
@ -1414,7 +1415,7 @@ class EntityManager
|
||||||
*entity_id = ID of entity to remove
|
*entity_id = ID of entity to remove
|
||||||
*tmpl = pointer entity template allocated by EntityManager.
|
*tmpl = pointer entity template allocated by EntityManager.
|
||||||
*/
|
*/
|
||||||
void addComponents(Components...)(const EntityID entity_id, Components comps)
|
void addComponents(Components...)(const EntityID entity_id, Components comps) nothrow @nogc
|
||||||
{
|
{
|
||||||
const uint num = Components.length;
|
const uint num = Components.length;
|
||||||
Entity* entity = id_manager.getEntityPointer(entity_id);
|
Entity* entity = id_manager.getEntityPointer(entity_id);
|
||||||
|
|
@ -1505,7 +1506,7 @@ class EntityManager
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Return block with free space for selected EntityInfo.
|
*Return block with free space for selected EntityInfo.
|
||||||
*/
|
*/
|
||||||
private EntitiesBlock* findBlockWithFreeSpace(EntityInfo* info)
|
private EntitiesBlock* findBlockWithFreeSpace(EntityInfo* info) nothrow @nogc
|
||||||
{
|
{
|
||||||
EntitiesBlock* block = info.last_block;
|
EntitiesBlock* block = info.last_block;
|
||||||
|
|
||||||
|
|
@ -1585,7 +1586,7 @@ class EntityManager
|
||||||
threads[thread_id].entities_to_remove.add(id);
|
threads[thread_id].entities_to_remove.add(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void __removeEntity(EntityID id)
|
private void __removeEntity(EntityID id) nothrow @nogc
|
||||||
{
|
{
|
||||||
//get entity and block meta data pointers
|
//get entity and block meta data pointers
|
||||||
Entity* entity = id_manager.getEntityPointer(id);
|
Entity* entity = id_manager.getEntityPointer(id);
|
||||||
|
|
@ -1598,7 +1599,7 @@ class EntityManager
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeEntityNoID(Entity* entity, EntitiesBlock* block,
|
private void removeEntityNoID(Entity* entity, EntitiesBlock* block,
|
||||||
bool call_destructors = false)
|
bool call_destructors = false) nothrow @nogc
|
||||||
{
|
{
|
||||||
//pos is Entity number in block
|
//pos is Entity number in block
|
||||||
void* data_begin = block.dataBegin();
|
void* data_begin = block.dataBegin();
|
||||||
|
|
@ -1662,7 +1663,7 @@ class EntityManager
|
||||||
*params:
|
*params:
|
||||||
*pointer = pointer to any data of entity (i.e. component data pointer)
|
*pointer = pointer to any data of entity (i.e. component data pointer)
|
||||||
*/
|
*/
|
||||||
export EntitiesBlock* getMetaData(const void* pointer)
|
export EntitiesBlock* getMetaData(const void* pointer) nothrow @nogc
|
||||||
{
|
{
|
||||||
return cast(EntitiesBlock*)(cast(size_t) pointer & (~cast(size_t)(page_size - 1)));
|
return cast(EntitiesBlock*)(cast(size_t) pointer & (~cast(size_t)(page_size - 1)));
|
||||||
}
|
}
|
||||||
|
|
@ -1726,7 +1727,7 @@ class EntityManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeEntities()
|
private void removeEntities() nothrow @nogc
|
||||||
{
|
{
|
||||||
foreach (i, ref thread; threads)
|
foreach (i, ref thread; threads)
|
||||||
{
|
{
|
||||||
|
|
@ -1738,7 +1739,7 @@ class EntityManager
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateEvents()
|
void updateEvents() nothrow @nogc
|
||||||
{
|
{
|
||||||
bool empty = true;
|
bool empty = true;
|
||||||
//uint index = event_manager.
|
//uint index = event_manager.
|
||||||
|
|
@ -1775,7 +1776,7 @@ class EntityManager
|
||||||
foreach(caller; events[i].callers)
|
foreach(caller; events[i].callers)
|
||||||
{
|
{
|
||||||
call_data.system_pointer = caller.system.m_system_pointer;
|
call_data.system_pointer = caller.system.m_system_pointer;
|
||||||
(cast(void function(ref EventCallData))caller.callback)(call_data);
|
(cast(void function(ref EventCallData) nothrow @nogc)caller.callback)(call_data);
|
||||||
}
|
}
|
||||||
event_pointer += events[i].size;
|
event_pointer += events[i].size;
|
||||||
}
|
}
|
||||||
|
|
@ -1834,21 +1835,21 @@ class EntityManager
|
||||||
//event_manager.clearEvents();
|
//event_manager.clearEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getThreadID()
|
private void getThreadID() nothrow @nogc
|
||||||
{
|
{
|
||||||
if (m_thread_id_func)
|
if (m_thread_id_func)
|
||||||
thread_id = m_thread_id_func();
|
thread_id = (cast(uint delegate() nothrow @nogc)m_thread_id_func)();
|
||||||
else
|
else
|
||||||
thread_id = 0;
|
thread_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendEvent(Ev)(EntityID id, Ev event)
|
void sendEvent(Ev)(EntityID id, Ev event) nothrow @nogc
|
||||||
{
|
{
|
||||||
event_manager.sendEvent(id, event, thread_id);
|
event_manager.sendEvent(id, event, thread_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private */
|
/*private */
|
||||||
void generateDependencies()
|
void generateDependencies() nothrow @nogc
|
||||||
{
|
{
|
||||||
foreach (pass_id, pass; passes)
|
foreach (pass_id, pass; passes)
|
||||||
{
|
{
|
||||||
|
|
@ -2009,7 +2010,7 @@ class EntityManager
|
||||||
///Initialization data
|
///Initialization data
|
||||||
ubyte[] init_data;
|
ubyte[] init_data;
|
||||||
///Pointer to component destroy callback
|
///Pointer to component destroy callback
|
||||||
void function(void* pointer) destroy_callback;
|
void function(void* pointer) nothrow @nogc destroy_callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct EventCaller
|
struct EventCaller
|
||||||
|
|
@ -2040,7 +2041,7 @@ class EntityManager
|
||||||
struct EntityInfo
|
struct EntityInfo
|
||||||
{
|
{
|
||||||
///Returns number of blocks
|
///Returns number of blocks
|
||||||
uint blocksCount()
|
uint blocksCount() nothrow @nogc
|
||||||
{
|
{
|
||||||
if (last_block)
|
if (last_block)
|
||||||
return last_block.id + 1;
|
return last_block.id + 1;
|
||||||
|
|
@ -2049,7 +2050,7 @@ class EntityManager
|
||||||
}
|
}
|
||||||
|
|
||||||
///Returns number of non empty blocks
|
///Returns number of non empty blocks
|
||||||
uint nonEmptyBlocksCount()
|
uint nonEmptyBlocksCount() nothrow @nogc
|
||||||
{
|
{
|
||||||
EntitiesBlock* block = last_block;
|
EntitiesBlock* block = last_block;
|
||||||
while (1)
|
while (1)
|
||||||
|
|
@ -2094,7 +2095,7 @@ class EntityManager
|
||||||
struct EntitiesBlock
|
struct EntitiesBlock
|
||||||
{
|
{
|
||||||
///return distance (in bytes) from begin of block to data
|
///return distance (in bytes) from begin of block to data
|
||||||
uint dataDelta()
|
uint dataDelta() nothrow @nogc
|
||||||
{
|
{
|
||||||
ushort dif = EntitiesBlock.sizeof;
|
ushort dif = EntitiesBlock.sizeof;
|
||||||
alignNum(dif, type_info.alignment);
|
alignNum(dif, type_info.alignment);
|
||||||
|
|
@ -2102,7 +2103,7 @@ class EntityManager
|
||||||
}
|
}
|
||||||
|
|
||||||
///return pointer to first element in block
|
///return pointer to first element in block
|
||||||
export void* dataBegin()
|
export void* dataBegin() nothrow @nogc
|
||||||
{
|
{
|
||||||
ushort dif = EntitiesBlock.sizeof;
|
ushort dif = EntitiesBlock.sizeof;
|
||||||
return cast(void*)&this + dif;
|
return cast(void*)&this + dif;
|
||||||
|
|
@ -2134,7 +2135,7 @@ class EntityManager
|
||||||
*/
|
*/
|
||||||
struct CallData
|
struct CallData
|
||||||
{
|
{
|
||||||
void update()
|
void update() nothrow @nogc
|
||||||
{
|
{
|
||||||
(cast(SytemFuncType) system.m_update)(this);
|
(cast(SytemFuncType) system.m_update)(this);
|
||||||
}
|
}
|
||||||
|
|
@ -2160,7 +2161,7 @@ class EntityManager
|
||||||
{
|
{
|
||||||
CallData[] callers;
|
CallData[] callers;
|
||||||
|
|
||||||
void execute()
|
void execute() nothrow @nogc
|
||||||
{
|
{
|
||||||
EntityManager.instance.getThreadID();
|
EntityManager.instance.getThreadID();
|
||||||
foreach (ref caller; callers)
|
foreach (ref caller; callers)
|
||||||
|
|
@ -2181,7 +2182,7 @@ class EntityManager
|
||||||
|
|
||||||
struct SystemCaller
|
struct SystemCaller
|
||||||
{
|
{
|
||||||
~this()
|
~this() nothrow @nogc
|
||||||
{
|
{
|
||||||
if (dependencies)
|
if (dependencies)
|
||||||
{
|
{
|
||||||
|
|
@ -2209,7 +2210,7 @@ class EntityManager
|
||||||
|
|
||||||
struct UpdatePass
|
struct UpdatePass
|
||||||
{
|
{
|
||||||
~this()
|
~this() nothrow @nogc
|
||||||
{
|
{
|
||||||
assert(name);
|
assert(name);
|
||||||
if (name)
|
if (name)
|
||||||
|
|
@ -2230,7 +2231,7 @@ class EntityManager
|
||||||
|
|
||||||
//Vector!(SystemCaller*) system_callers;
|
//Vector!(SystemCaller*) system_callers;
|
||||||
|
|
||||||
alias SytemFuncType = void function(ref EntityManager.CallData data);
|
alias SytemFuncType = void function(ref EntityManager.CallData data) nothrow @nogc;
|
||||||
|
|
||||||
//alias sendSelfEvent = instance.event_manager.sendSelfEvent;
|
//alias sendSelfEvent = instance.event_manager.sendSelfEvent;
|
||||||
|
|
||||||
|
|
@ -2278,7 +2279,7 @@ class EntityManager
|
||||||
Vector!(Block*) blocks;
|
Vector!(Block*) blocks;
|
||||||
uint id;
|
uint id;
|
||||||
|
|
||||||
void clear()
|
void clear() nothrow @nogc
|
||||||
{
|
{
|
||||||
if (blocks.length > 0)
|
if (blocks.length > 0)
|
||||||
foreach (block; blocks[0 .. id + 1])
|
foreach (block; blocks[0 .. id + 1])
|
||||||
|
|
@ -2289,7 +2290,7 @@ class EntityManager
|
||||||
//blocks.clear();
|
//blocks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
CallData[] getCallData(uint num)
|
CallData[] getCallData(uint num) nothrow @nogc
|
||||||
{
|
{
|
||||||
if (blocks.length == 0)
|
if (blocks.length == 0)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import std.traits : Parameters;
|
||||||
private __gshared static HashMap!(const(char)[], StringIntern) gStringInterns;
|
private __gshared static HashMap!(const(char)[], StringIntern) gStringInterns;
|
||||||
|
|
||||||
struct StringIntern {
|
struct StringIntern {
|
||||||
|
|
||||||
private const(char)* strPtr;
|
private const(char)* strPtr;
|
||||||
|
|
||||||
this(const(char)[] fromStr) {
|
this(const(char)[] fromStr) {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ struct System
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Check if system is enabled.
|
*Check if system is enabled.
|
||||||
*/
|
*/
|
||||||
export bool enabled()
|
export bool enabled() nothrow @nogc
|
||||||
{
|
{
|
||||||
return m_enabled;
|
return m_enabled;
|
||||||
}
|
}
|
||||||
|
|
@ -20,27 +20,27 @@ struct System
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Enable system. If actually it is enabled function do nothing.
|
*Enable system. If actually it is enabled function do nothing.
|
||||||
*/
|
*/
|
||||||
export void enable()
|
export void enable() nothrow @nogc
|
||||||
{
|
{
|
||||||
if (!m_enabled && m_enable)
|
if (!m_enabled && m_enable)
|
||||||
(cast(void function(void*))m_enable)(m_system_pointer);
|
(cast(void function(void*) nothrow @nogc)m_enable)(m_system_pointer);
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Disable system. If actually it is disabled function do nothing.
|
*Disable system. If actually it is disabled function do nothing.
|
||||||
*/
|
*/
|
||||||
export void disable()
|
export void disable() nothrow @nogc
|
||||||
{
|
{
|
||||||
if (m_enabled && m_disable)
|
if (m_enabled && m_disable)
|
||||||
(cast(void function(void*))m_disable)(m_system_pointer);
|
(cast(void function(void*) nothrow @nogc)m_disable)(m_system_pointer);
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Get system priority.
|
*Get system priority.
|
||||||
*/
|
*/
|
||||||
export int priority()
|
export int priority() nothrow @nogc
|
||||||
{
|
{
|
||||||
return m_priority;
|
return m_priority;
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +48,7 @@ struct System
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Get system priority.
|
*Get system priority.
|
||||||
*/
|
*/
|
||||||
export bool execute()
|
export bool execute() nothrow @nogc
|
||||||
{
|
{
|
||||||
return m_execute;
|
return m_execute;
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ struct System
|
||||||
/************************************************************************************************************************
|
/************************************************************************************************************************
|
||||||
*Get system priority.
|
*Get system priority.
|
||||||
*/
|
*/
|
||||||
export ushort id()
|
export ushort id() nothrow @nogc
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -284,7 +284,7 @@ struct TestSystem2
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
|
||||||
void dispatch(EntityManager.JobGroup jobs)
|
void dispatch(EntityManager.JobGroup jobs) nothrow @nogc
|
||||||
{
|
{
|
||||||
foreach(job;jobs.jobs)
|
foreach(job;jobs.jobs)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue