Skip to content

Commit

Permalink
feat: use async
Browse files Browse the repository at this point in the history
  • Loading branch information
developer239 committed Dec 24, 2023
1 parent 414b666 commit a2c432f
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/apps/day14/src/strategies/ECSStrategy.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include <future>
#include <optional>

#include "core/AssetStore.h"
Expand All @@ -23,7 +24,7 @@ std::string filePath = "assets/input.txt";

class MinimalLoopStrategy : public Core::IStrategy {
public:
float scale = 10.0f;
float scale = 20.0f;
int numRows = 0;
int numCols = 0;

Expand Down Expand Up @@ -198,18 +199,18 @@ class MinimalLoopStrategy : public Core::IStrategy {
Core::Window& window, Core::Renderer& renderer, double deltaTime
) override {

ECS::Registry::Instance().GetSystem<CollisionSystem>().Update(1);
for (int column = 0; column < numCols; column++) {
auto future = std::async(
std::launch::async,
&CollisionSystem::Update,
&ECS::Registry::Instance().GetSystem<CollisionSystem>(),
column
);
}

ECS::Registry::Instance().GetSystem<PuzzleSolverSystem>().Update();

ECS::Registry::Instance().Update();

// ECS::Registry::Instance()
// .GetSystem<PuzzleSolverSystem>()
// .CalculateSumOfAllParts(puzzleSolverEntity1.value());
// ECS::Registry::Instance()
// .GetSystem<PuzzleSolverSystem>()
// .CalculateSumAllGearRatios(puzzleSolverEntity2.value());
}

void OnRender(Core::Window& window, Core::Renderer& renderer) override {
Expand Down

0 comments on commit a2c432f

Please sign in to comment.