Chunks render moved to ChunksLoader

This commit is contained in:
MihailRis
2022-06-29 19:30:23 +03:00
committed by GitHub
parent 15bed4169e
commit f569378b88
12 changed files with 127 additions and 43 deletions
+11 -4
View File
@@ -12,19 +12,25 @@
class Chunk;
enum LoaderMode {
OFF, IDLE, LOAD, RENDER,
};
class ChunksLoader final {
private:
std::thread loaderThread;
void _thread();
std::atomic<Chunk*> current {nullptr};
std::atomic<Chunk**> closes {nullptr};
std::atomic<bool> working {true};
std::atomic<LoaderMode> state {IDLE};
void perform(Chunk* chunk, Chunk** closes_passed, LoaderMode mode);
public:
ChunksLoader() : loaderThread{} {
loaderThread = std::thread{&ChunksLoader::_thread, this};
}
~ChunksLoader(){
working = false;
state = OFF;
loaderThread.join();
}
@@ -32,10 +38,11 @@ public:
return current != nullptr;
}
void perform(Chunk* chunk, Chunk** closes_passed);
void load(Chunk* chunk, Chunk** closes_passed);
void render(Chunk* chunk, Chunk** closes_passed);
void stop(){
working = false;
state = OFF;
}
};