From a43528ab069f325e68dab6e18cf2cab19cc22e56 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 18 Sep 2016 08:24:25 -0400 Subject: Clean up code --- src/server/PreProcessor.hpp | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'src/server/PreProcessor.hpp') diff --git a/src/server/PreProcessor.hpp b/src/server/PreProcessor.hpp index f9b85c8f..5dc7bef0 100644 --- a/src/server/PreProcessor.hpp +++ b/src/server/PreProcessor.hpp @@ -49,22 +49,31 @@ public: /** Process events for a cycle. * @return The number of events processed. */ - unsigned process(RunContext& context, - PostProcessor& dest, - size_t limit = 0); + unsigned process(RunContext& context, + PostProcessor& dest, + size_t limit = 0); protected: void run(); private: - Engine& _engine; - std::mutex _mutex; - Raul::Semaphore _sem; - std::atomic _head; - std::atomic _prepared_back; - std::atomic _tail; - bool _exit_flag; - std::thread _thread; + enum class BlockState { + UNBLOCKED, ///< Normal, unblocked execution + PRE_BLOCKED, ///< Preprocess thread has enqueued blocking event + BLOCKED, ///< Process thread has reached blocking event + PRE_UNBLOCKED, ///< Preprocess thread has enqueued unblocking event + PROCESSING ///< Process thread is executing all events in-between + }; + + Engine& _engine; + std::mutex _mutex; + Raul::Semaphore _sem; + std::atomic _head; + std::atomic _prepared_back; + std::atomic _tail; + std::atomic _block_state; + bool _exit_flag; + std::thread _thread; }; } // namespace Server -- cgit v1.2.1