|
group2 0.1.0
CSE 125 Group 2
|
Thin wrapper around C++17 parallel STL. More...
#include <SDL3/SDL.h>#include <algorithm>#include <atomic>#include <cstdlib>Go to the source code of this file.
Namespaces | |
| namespace | group2 |
| namespace | group2::perf |
Functions | |
| void | group2::perf::initParallelFromEnv () |
| Initialize from environment. | |
| template<class Iter, class Fn> | |
| void | group2::perf::parallelFor (Iter begin, Iter end, Fn &&fn) |
| Call fn(*it) for every element in [begin, end). | |
Variables | |
| std::atomic< bool > | group2::perf::parallelEnabled {true} |
| Master switch for parallel execution. | |
| constexpr std::size_t | group2::perf::k_parallelThreshold = 64 |
| Minimum items below which parallelFor runs sequentially even when the master switch is on. | |
Thin wrapper around C++17 parallel STL.
PR-3 (server-perf): the per-system game-thread work is largely embarrassingly parallel across players (animation update, hitbox capsule transform, swept collision, etc.). This header gives the systems a single, opinionated entry point — group2::perf::parallelFor(begin, end, fn) — that hides the libstdc++ parallel-STL details.
Implementation policy:
Determinism: lag-comp + hitscan rely on the simulation being deterministic across the network/recording boundary. par_unseq reorders operations across iterations BUT operates only on independent per-entity slots, so the observable result is identical to a sequential pass. We add a GROUP2_SERVER_PARALLEL=0 kill-switch (read once at startup) to fall back to sequential if a regression turns up — the brain wants the diff to be exactly "thread count" so repro is easy.