Files
Seele/src/Engine/Scene/SceneUpdater.h
T

32 lines
781 B
C++
Raw Normal View History

2021-04-25 23:43:40 +02:00
#pragma once
2021-10-23 00:22:35 +02:00
#include "MinimalEngine.h"
2021-05-06 17:02:10 +02:00
#include "Containers/List.h"
#include <semaphore>
2021-04-25 23:43:40 +02:00
namespace Seele
{
2021-05-06 17:02:10 +02:00
DECLARE_REF(Component);
DECLARE_REF(Actor);
2021-04-25 23:43:40 +02:00
class SceneUpdater
{
public:
SceneUpdater();
~SceneUpdater();
2021-05-06 17:02:10 +02:00
void registerComponentUpdate(PComponent component);
void registerActorUpdate(PActor actor);
void runUpdates(float delta);
2021-04-25 23:43:40 +02:00
private:
Array<std::thread> workers;
2021-05-06 17:02:10 +02:00
std::mutex pendingUpdatesLock;
std::counting_semaphore<> pendingUpdatesSem;
List<std::function<void(float)>> pendingUpdates;
List<std::function<void(float)>> updatesRan;
2021-04-25 23:43:40 +02:00
void work();
2021-05-06 17:02:10 +02:00
float frameDelta;
std::atomic_bool running;
std::mutex frameFinishedLock;
std::condition_variable frameFinishedCV;
2021-04-25 23:43:40 +02:00
};
2021-05-06 17:02:10 +02:00
DEFINE_REF(SceneUpdater)
2021-04-25 23:43:40 +02:00
} // namespace Seele