Merge branch 'master' into cxx17

This commit is contained in:
Stephen Seo 2022-01-20 14:34:31 +09:00
commit f009ef1135

View file

@ -104,6 +104,7 @@ namespace EC
EntitiesType *entities; EntitiesType *entities;
const BitsetType *signature; const BitsetType *signature;
void *userData; void *userData;
std::unordered_set<std::size_t> dead;
}; };
/// Temporary struct used internally by ThreadPool /// Temporary struct used internally by ThreadPool
template <typename Function> template <typename Function>
@ -114,6 +115,7 @@ namespace EC
BitsetType *signature; BitsetType *signature;
void *userData; void *userData;
Function *fn; Function *fn;
std::unordered_set<std::size_t> dead;
}; };
/// Temporary struct used internally by ThreadPool /// Temporary struct used internally by ThreadPool
struct TPFnDataStructTwo { struct TPFnDataStructTwo {
@ -122,6 +124,7 @@ namespace EC
EntitiesType *entities; EntitiesType *entities;
void *userData; void *userData;
const std::vector<std::size_t> *matching; const std::vector<std::size_t> *matching;
std::unordered_set<std::size_t> dead;
}; };
/// Temporary struct used internally by ThreadPool /// Temporary struct used internally by ThreadPool
struct TPFnDataStructThree { struct TPFnDataStructThree {
@ -131,6 +134,7 @@ namespace EC
const std::vector<BitsetType*> *bitsets; const std::vector<BitsetType*> *bitsets;
EntitiesType *entities; EntitiesType *entities;
std::mutex *mutex; std::mutex *mutex;
std::unordered_set<std::size_t> dead;
}; };
/// Temporary struct used internally by ThreadPool /// Temporary struct used internally by ThreadPool
struct TPFnDataStructFour { struct TPFnDataStructFour {
@ -140,6 +144,7 @@ namespace EC
multiMatchingEntities; multiMatchingEntities;
BitsetType *signatures; BitsetType *signatures;
std::mutex *mutex; std::mutex *mutex;
std::unordered_set<std::size_t> dead;
}; };
/// Temporary struct used internally by ThreadPool /// Temporary struct used internally by ThreadPool
struct TPFnDataStructFive { struct TPFnDataStructFive {
@ -149,6 +154,7 @@ namespace EC
void *userData; void *userData;
std::vector<std::vector<std::size_t> >* std::vector<std::vector<std::size_t> >*
multiMatchingEntities; multiMatchingEntities;
std::unordered_set<std::size_t> dead;
}; };
/// Temporary struct used internally by ThreadPool /// Temporary struct used internally by ThreadPool
struct TPFnDataStructSix { struct TPFnDataStructSix {
@ -158,6 +164,7 @@ namespace EC
multiMatchingEntities; multiMatchingEntities;
BitsetType *bitsets; BitsetType *bitsets;
std::mutex *mutex; std::mutex *mutex;
std::unordered_set<std::size_t> dead;
}; };
/// Temporary struct used internally by ThreadPool /// Temporary struct used internally by ThreadPool
template <typename Iterable> template <typename Iterable>
@ -167,6 +174,7 @@ namespace EC
EntitiesType *entities; EntitiesType *entities;
Iterable *iterable; Iterable *iterable;
void *userData; void *userData;
std::unordered_set<std::size_t> dead;
}; };
// end section for "temporary" structures }}} // end section for "temporary" structures }}}
@ -752,12 +760,17 @@ namespace EC
fnDataAr[i].entities = &entities; fnDataAr[i].entities = &entities;
fnDataAr[i].signature = &signatureBitset; fnDataAr[i].signature = &signatureBitset;
fnDataAr[i].userData = userData; fnDataAr[i].userData = userData;
for(std::size_t j = begin; j < end; ++j) {
if(!isAlive(j)) {
fnDataAr[i].dead.insert(j);
}
}
threadPool->queueFn([&function] (void *ud) { threadPool->queueFn([&function] (void *ud) {
auto *data = static_cast<TPFnDataStructZero*>(ud); auto *data = static_cast<TPFnDataStructZero*>(ud);
for(std::size_t i = data->range[0]; i < data->range[1]; for(std::size_t i = data->range[0]; i < data->range[1];
++i) { ++i) {
if(!data->manager->isAlive(i)) { if(data->dead.find(i) != data->dead.end()) {
continue; continue;
} }
@ -870,11 +883,16 @@ namespace EC
fnDataAr[i].signature = &signatureBitset; fnDataAr[i].signature = &signatureBitset;
fnDataAr[i].userData = userData; fnDataAr[i].userData = userData;
fnDataAr[i].fn = function; fnDataAr[i].fn = function;
for(std::size_t j = begin; j < end; ++j) {
if(!isAlive(j)) {
fnDataAr[i].dead.insert(j);
}
}
threadPool->queueFn([] (void *ud) { threadPool->queueFn([] (void *ud) {
auto *data = static_cast<TPFnDataStructOne<Function>*>(ud); auto *data = static_cast<TPFnDataStructOne<Function>*>(ud);
for(std::size_t i = data->range[0]; i < data->range[1]; for(std::size_t i = data->range[0]; i < data->range[1];
++i) { ++i) {
if(!data->manager->isAlive(i)) { if(data->dead.find(i) != data->dead.end()) {
continue; continue;
} }
@ -1015,13 +1033,17 @@ namespace EC
fnDataAr[i].entities = &entities; fnDataAr[i].entities = &entities;
fnDataAr[i].userData = userData; fnDataAr[i].userData = userData;
fnDataAr[i].matching = &matching; fnDataAr[i].matching = &matching;
for(std::size_t j = begin; j < end; ++j) {
if(!isAlive(matching.at(j))) {
fnDataAr[i].dead.insert(j);
}
}
threadPool->queueFn([&function, helper] (void* ud) { threadPool->queueFn([&function, helper] (void* ud) {
auto *data = static_cast<TPFnDataStructTwo*>(ud); auto *data = static_cast<TPFnDataStructTwo*>(ud);
for(std::size_t i = data->range[0]; for(std::size_t i = data->range[0];
i < data->range[1]; i < data->range[1];
++i) { ++i) {
if(data->manager->isAlive( if(data->dead.find(i) == data->dead.end()) {
data->matching->at(i))) {
helper.callInstancePtr( helper.callInstancePtr(
data->matching->at(i), data->matching->at(i),
*data->manager, *data->manager,
@ -1085,11 +1107,16 @@ namespace EC
fnDataAr[i].bitsets = &bitsets; fnDataAr[i].bitsets = &bitsets;
fnDataAr[i].entities = &entities; fnDataAr[i].entities = &entities;
fnDataAr[i].mutex = &mutex; fnDataAr[i].mutex = &mutex;
for(std::size_t j = begin; j < end; ++j) {
if(!isAlive(j)) {
fnDataAr[i].dead.insert(j);
}
}
threadPool->queueFn([] (void *ud) { threadPool->queueFn([] (void *ud) {
auto *data = static_cast<TPFnDataStructThree*>(ud); auto *data = static_cast<TPFnDataStructThree*>(ud);
for(std::size_t i = data->range[0]; i < data->range[1]; for(std::size_t i = data->range[0]; i < data->range[1];
++i) { ++i) {
if(!data->manager->isAlive(i)) { if(data->dead.find(i) != data->dead.end()) {
continue; continue;
} }
for(std::size_t j = 0; j < data->bitsets->size(); for(std::size_t j = 0; j < data->bitsets->size();
@ -1457,12 +1484,17 @@ namespace EC
fnDataAr[i].multiMatchingEntities = &multiMatchingEntities; fnDataAr[i].multiMatchingEntities = &multiMatchingEntities;
fnDataAr[i].signatures = signatureBitsets; fnDataAr[i].signatures = signatureBitsets;
fnDataAr[i].mutex = &mutex; fnDataAr[i].mutex = &mutex;
for(std::size_t j = begin; j < end; ++j) {
if(!isAlive(j)) {
fnDataAr[i].dead.insert(j);
}
}
threadPool->queueFn([] (void *ud) { threadPool->queueFn([] (void *ud) {
auto *data = static_cast<TPFnDataStructFour*>(ud); auto *data = static_cast<TPFnDataStructFour*>(ud);
for(std::size_t i = data->range[0]; i < data->range[1]; for(std::size_t i = data->range[0]; i < data->range[1];
++i) { ++i) {
if(!data->manager->isAlive(i)) { if(data->dead.find(i) != data->dead.end()) {
continue; continue;
} }
for(std::size_t j = 0; j < SigList::size; ++j) { for(std::size_t j = 0; j < SigList::size; ++j) {
@ -1524,13 +1556,16 @@ namespace EC
fnDataAr[i].userData = userData; fnDataAr[i].userData = userData;
fnDataAr[i].multiMatchingEntities = fnDataAr[i].multiMatchingEntities =
&multiMatchingEntities; &multiMatchingEntities;
for(std::size_t j = begin; j < end; ++j) {
if(!isAlive(multiMatchingEntities.at(index).at(j))) {
fnDataAr[i].dead.insert(j);
}
}
threadPool->queueFn([&func] (void *ud) { threadPool->queueFn([&func] (void *ud) {
auto *data = static_cast<TPFnDataStructFive*>(ud); auto *data = static_cast<TPFnDataStructFive*>(ud);
for(std::size_t i = data->range[0]; for(std::size_t i = data->range[0];
i < data->range[1]; ++i) { i < data->range[1]; ++i) {
if(data->manager->isAlive( if(data->dead.find(i) == data->dead.end()) {
data->multiMatchingEntities
->at(data->index).at(i))) {
Helper::call( Helper::call(
data->multiMatchingEntities data->multiMatchingEntities
->at(data->index).at(i), ->at(data->index).at(i),
@ -1657,12 +1692,17 @@ namespace EC
fnDataAr[i].multiMatchingEntities = &multiMatchingEntities; fnDataAr[i].multiMatchingEntities = &multiMatchingEntities;
fnDataAr[i].bitsets = signatureBitsets; fnDataAr[i].bitsets = signatureBitsets;
fnDataAr[i].mutex = &mutex; fnDataAr[i].mutex = &mutex;
for(std::size_t j = begin; j < end; ++j) {
if(!isAlive(j)) {
fnDataAr[i].dead.insert(j);
}
}
threadPool->queueFn([] (void *ud) { threadPool->queueFn([] (void *ud) {
auto *data = static_cast<TPFnDataStructSix*>(ud); auto *data = static_cast<TPFnDataStructSix*>(ud);
for(std::size_t i = data->range[0]; i < data->range[1]; for(std::size_t i = data->range[0]; i < data->range[1];
++i) { ++i) {
if(!data->manager->isAlive(i)) { if(data->dead.find(i) != data->dead.end()) {
continue; continue;
} }
for(std::size_t j = 0; j < SigList::size; ++j) { for(std::size_t j = 0; j < SigList::size; ++j) {
@ -1729,13 +1769,16 @@ namespace EC
fnDataAr[i].userData = userData; fnDataAr[i].userData = userData;
fnDataAr[i].multiMatchingEntities = fnDataAr[i].multiMatchingEntities =
&multiMatchingEntities; &multiMatchingEntities;
for(std::size_t j = begin; j < end; ++j) {
if(!isAlive(multiMatchingEntities.at(index).at(j))) {
fnDataAr[i].dead.insert(j);
}
}
threadPool->queueFn([&func] (void *ud) { threadPool->queueFn([&func] (void *ud) {
auto *data = static_cast<TPFnDataStructFive*>(ud); auto *data = static_cast<TPFnDataStructFive*>(ud);
for(std::size_t i = data->range[0]; for(std::size_t i = data->range[0];
i < data->range[1]; ++i) { i < data->range[1]; ++i) {
if(data->manager->isAlive( if(data->dead.find(i) == data->dead.end()) {
data->multiMatchingEntities
->at(data->index).at(i))) {
Helper::callPtr( Helper::callPtr(
data->multiMatchingEntities data->multiMatchingEntities
->at(data->index).at(i), ->at(data->index).at(i),
@ -1809,13 +1852,18 @@ namespace EC
fnDataAr[i].entities = &entities; fnDataAr[i].entities = &entities;
fnDataAr[i].signature = &signatureBitset; fnDataAr[i].signature = &signatureBitset;
fnDataAr[i].userData = userData; fnDataAr[i].userData = userData;
for(std::size_t j = begin; j < end; ++j) {
if(!isAlive(j)) {
fnDataAr[i].dead.insert(j);
}
}
threadPool->queueFn([&fn] (void *ud) { threadPool->queueFn([&fn] (void *ud) {
auto *data = static_cast<TPFnDataStructZero*>(ud); auto *data = static_cast<TPFnDataStructZero*>(ud);
for(std::size_t i = data->range[0]; i < data->range[1]; for(std::size_t i = data->range[0]; i < data->range[1];
++i) { ++i) {
if(!data->manager->isAlive(i)) { if(data->dead.find(i) != data->dead.end()) {
continue; continue;
} else if((*data->signature } else if((*data->signature
& std::get<BitsetType>( & std::get<BitsetType>(
data->entities->at(i))) data->entities->at(i)))
== *data->signature) { == *data->signature) {
@ -1891,12 +1939,17 @@ namespace EC
fnDataAr[i].entities = &entities; fnDataAr[i].entities = &entities;
fnDataAr[i].iterable = &iterable; fnDataAr[i].iterable = &iterable;
fnDataAr[i].userData = userData; fnDataAr[i].userData = userData;
for(std::size_t j = begin; j < end; ++j) {
if(!isAlive(j)) {
fnDataAr[i].dead.insert(j);
}
}
threadPool->queueFn([&fn] (void *ud) { threadPool->queueFn([&fn] (void *ud) {
auto *data = static_cast<TPFnDataStructSeven<Iterable>*>(ud); auto *data = static_cast<TPFnDataStructSeven<Iterable>*>(ud);
bool isValid; bool isValid;
for(std::size_t i = data->range[0]; i < data->range[1]; for(std::size_t i = data->range[0]; i < data->range[1];
++i) { ++i) {
if(!data->manager->isAlive(i)) { if(data->dead.find(i) != data->dead.end()) {
continue; continue;
} }
isValid = true; isValid = true;