diff options
Diffstat (limited to 'Museum.cpp')
-rw-r--r-- | Museum.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -1,5 +1,32 @@ #include "Museum.h" +using namespace std; + +Museum::Museum() { + this->worker = new std::thread(&Museum::work, this); +} + +Museum::~Museum() { + this->working = false; + this->worker->join(); + if (this->worker != nullptr) { + delete this->worker; + this->worker = nullptr; + } +} + void Museum::update() { + this->people.update(); + // this->canvas.update(); +} + +void Museum::work() { + while (this->working) { + if (this->paused) continue; // wait if paused + + auto next = chrono::steady_clock::now() + this->tick_interval; + this->update(); + this_thread::sleep_until(next); + } } |