diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-24 01:38:30 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-09-24 01:38:30 +0200 |
commit | ea8840291cdf66784c6a2cb465b63ccfb5483c38 (patch) | |
tree | 0ab1e059c3b798d27f8d9a15816c7beb0dd236e8 /src/control/RPGEdit.hpp | |
parent | 24ae84861379f2f878804b53a457153ad1ad6c1e (diff) | |
download | rpgedit-ea8840291cdf66784c6a2cb465b63ccfb5483c38.tar rpgedit-ea8840291cdf66784c6a2cb465b63ccfb5483c38.zip |
New event-driven goodness
Diffstat (limited to 'src/control/RPGEdit.hpp')
-rw-r--r-- | src/control/RPGEdit.hpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/control/RPGEdit.hpp b/src/control/RPGEdit.hpp index f045265..8b5e697 100644 --- a/src/control/RPGEdit.hpp +++ b/src/control/RPGEdit.hpp @@ -30,8 +30,10 @@ #include "InputHandler.hpp" #include "MapContext.hpp" +#include <condition_variable> #include <memory> #include <mutex> +#include <thread> namespace RPGEdit { @@ -40,6 +42,8 @@ namespace Control { class RPGEdit { private: + TimeProvider timeProvider; + EventBus eventBus; InputHandler inputHandler; ImageLoader tileLoader; @@ -49,11 +53,20 @@ private: std::shared_ptr<View::Window> window; std::shared_ptr<View::MapView> mapView; - std::mutex modelLock; + std::thread eventThread; + std::mutex modelMutex; + std::condition_variable modelCond; + uint64_t handledTime = std::numeric_limits<uint64_t>::max(); + + void enqueueNow(const EventBus::Event &event) { + eventBus.enqueue(event, timeProvider.now()); + } - bool systemIter(unsigned ticks); + bool handleSystemEvent(const SDL_Event &event); void systemLoop(); + void eventLoop(); + public: void run(); }; |