#include "Museum.h" using namespace std; Museum::Museum() : people(*this), canvas(*this) { 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); } } void Museum::set_pause(bool paused) { this->paused = paused; }