From ea8840291cdf66784c6a2cb465b63ccfb5483c38 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Wed, 24 Sep 2014 01:38:30 +0200 Subject: New event-driven goodness --- src/control/RPGEdit.hpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/control/RPGEdit.hpp') 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 #include #include +#include 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 window; std::shared_ptr mapView; - std::mutex modelLock; + std::thread eventThread; + std::mutex modelMutex; + std::condition_variable modelCond; + uint64_t handledTime = std::numeric_limits::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(); }; -- cgit v1.2.3