-added more documentation
-remove update() function from entity -currently max supported components count is 64 per type
This commit is contained in:
parent
546b73c567
commit
845f468d59
10 changed files with 199 additions and 64 deletions
|
|
@ -1,3 +1,9 @@
|
|||
/************************************************************************************************************************
|
||||
*It's internal code. Can be used for atomics if emscripten backend will be used.
|
||||
*
|
||||
*This module contain atomic operations which include support for emscripten atomics functions.
|
||||
*Emscripten functions are contained in API similar to druntime.
|
||||
*/
|
||||
module ecs.atomic;
|
||||
|
||||
version(Emscripten)version = ECSEmscripten;
|
||||
|
|
@ -14,7 +20,7 @@ version(ECSEmscripten)
|
|||
rel,
|
||||
seq
|
||||
}
|
||||
|
||||
|
||||
extern(C) ubyte emscripten_atomic_cas_u8(void *addr, ubyte oldVal, ubyte newVal) @nogc nothrow pure;
|
||||
extern(C) ushort emscripten_atomic_cas_u16(void *addr, ushort oldVal, ushort newVal) @nogc nothrow pure;
|
||||
extern(C) uint emscripten_atomic_cas_u32(void *addr, uint oldVal, uint newVal) @nogc nothrow pure;
|
||||
|
|
@ -35,7 +41,7 @@ version(ECSEmscripten)
|
|||
extern(C) ushort emscripten_atomic_sub_u16(void *addr, ushort val) @nogc nothrow pure;
|
||||
extern(C) uint emscripten_atomic_sub_u32(void *addr, uint val) @nogc nothrow pure;
|
||||
|
||||
pure nothrow @nogc Unqual!T atomicOp(string op, T, V1)(ref shared T val, V1 mod)
|
||||
public pure nothrow @nogc Unqual!T atomicOp(string op, T, V1)(ref shared T val, V1 mod)
|
||||
{
|
||||
static if(op == "+=")
|
||||
{
|
||||
|
|
@ -53,7 +59,7 @@ version(ECSEmscripten)
|
|||
}
|
||||
}
|
||||
|
||||
pure nothrow @nogc @trusted void atomicStore(MemoryOrder ms = MemoryOrder.seq, T, V)(ref T val, V newval)
|
||||
public pure nothrow @nogc @trusted void atomicStore(MemoryOrder ms = MemoryOrder.seq, T, V)(ref T val, V newval)
|
||||
{
|
||||
alias UT = Unqual!T;
|
||||
static if(is(UT == bool) || is(UT == byte) || is(UT == ubyte))emscripten_atomic_store_u8(cast(void*)&val, cast(UT)newval);
|
||||
|
|
@ -62,7 +68,7 @@ version(ECSEmscripten)
|
|||
else static assert(0);
|
||||
}
|
||||
|
||||
pure nothrow @nogc @trusted T atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)(ref const T val)
|
||||
public pure nothrow @nogc @trusted T atomicLoad(MemoryOrder ms = MemoryOrder.seq, T)(ref const T val)
|
||||
{
|
||||
alias UT = Unqual!T;
|
||||
static if(is(UT == bool))return emscripten_atomic_load_u8(cast(const void*)&val) != 0;
|
||||
|
|
@ -72,7 +78,7 @@ version(ECSEmscripten)
|
|||
else static assert(0);
|
||||
}
|
||||
|
||||
pure nothrow @nogc @trusted bool cas(MemoryOrder succ = MemoryOrder.seq, MemoryOrder fail = MemoryOrder.seq, T, V1, V2)(T* here, V1 ifThis, V2 writeThis)
|
||||
public pure nothrow @nogc @trusted bool cas(MemoryOrder succ = MemoryOrder.seq, MemoryOrder fail = MemoryOrder.seq, T, V1, V2)(T* here, V1 ifThis, V2 writeThis)
|
||||
{
|
||||
alias UT = Unqual!T;
|
||||
static if(is(UT == bool))return emscripten_atomic_cas_u8(cast(void*)here, cast(Unqual!T)ifThis, cast(Unqual!T)writeThis) == ifThis;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue