diff options
author | wvpm <24685035+wvpm@users.noreply.github.com> | 2024-11-15 09:57:28 +0100 |
---|---|---|
committer | wvpm <24685035+wvpm@users.noreply.github.com> | 2024-11-15 09:57:28 +0100 |
commit | 25051fad3eb8988b2ed41a607120c99b7da2deca (patch) | |
tree | 5437ac2d51ee736ee6a7f0b72596f31a22bff192 /src | |
parent | a8ef75c96c579f74ee68789c5879df5262e36220 (diff) |
Process provinces in parallelparallel_tick
Diffstat (limited to 'src')
-rw-r--r-- | src/openvic-simulation/map/MapInstance.cpp | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/src/openvic-simulation/map/MapInstance.cpp b/src/openvic-simulation/map/MapInstance.cpp index 28bf189..d53ae0a 100644 --- a/src/openvic-simulation/map/MapInstance.cpp +++ b/src/openvic-simulation/map/MapInstance.cpp @@ -1,5 +1,7 @@ #include "MapInstance.hpp" +#include <execution> + #include "openvic-simulation/history/ProvinceHistory.hpp" #include "openvic-simulation/map/MapDefinition.hpp" #include "openvic-simulation/utility/Logger.hpp" @@ -161,9 +163,15 @@ void MapInstance::update_gamestate(const Date today, DefineManager const& define } void MapInstance::map_tick(const Date today) { - for (ProvinceInstance& province : province_instances.get_items()) { - province.province_tick(today); - } + std::vector<ProvinceInstance>& provinces = province_instances.get_items(); + std::for_each( + std::execution::par, + provinces.begin(), + provinces.end(), + [today](ProvinceInstance& province) -> void { + province.province_tick(today); + } + ); } void MapInstance::initialise_for_new_game( @@ -171,8 +179,14 @@ void MapInstance::initialise_for_new_game( DefineManager const& define_manager ) { update_gamestate(today, define_manager); - for (ProvinceInstance& province : province_instances.get_items()) { - province.initialise_rgo(); - province.province_tick(today); - } + std::vector<ProvinceInstance>& provinces = province_instances.get_items(); + std::for_each( + std::execution::par, + provinces.begin(), + provinces.end(), + [today](ProvinceInstance& province) -> void { + province.initialise_rgo(); + province.province_tick(today); + } + ); }
\ No newline at end of file |