summaryrefslogtreecommitdiffstats
path: root/src/server/PreProcessor.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/PreProcessor.hpp')
-rw-r--r--src/server/PreProcessor.hpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/server/PreProcessor.hpp b/src/server/PreProcessor.hpp
index 8d15c0a6..03ba5dd7 100644
--- a/src/server/PreProcessor.hpp
+++ b/src/server/PreProcessor.hpp
@@ -19,7 +19,7 @@
#include "Event.hpp"
-#include "raul/Semaphore.hpp"
+#include <raul/Semaphore.hpp>
#include <atomic>
#include <chrono>
@@ -27,8 +27,7 @@
#include <mutex>
#include <thread>
-namespace ingen {
-namespace server {
+namespace ingen::server {
class Engine;
class PostProcessor;
@@ -42,7 +41,7 @@ public:
~PreProcessor();
/** Return true iff no events are enqueued. */
- inline bool empty() const { return !_head.load(); }
+ bool empty() const { return !_head.load(); }
/** Enqueue an event.
* This is safe to call from any non-realtime thread (it locks).
@@ -52,7 +51,7 @@ public:
/** Process events for a cycle.
* @return The number of events processed.
*/
- unsigned process(RunContext& context,
+ unsigned process(RunContext& ctx,
PostProcessor& dest,
size_t limit = 0);
@@ -61,11 +60,11 @@ protected:
private:
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
+ 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
};
void wait_for_block_state(const BlockState state) {
@@ -76,15 +75,14 @@ private:
Engine& _engine;
std::mutex _mutex;
- Raul::Semaphore _sem;
- std::atomic<Event*> _head;
- std::atomic<Event*> _tail;
- std::atomic<BlockState> _block_state;
- bool _exit_flag;
+ raul::Semaphore _sem{0};
+ std::atomic<Event*> _head{nullptr};
+ std::atomic<Event*> _tail{nullptr};
+ std::atomic<BlockState> _block_state{BlockState::UNBLOCKED};
+ bool _exit_flag{false};
std::thread _thread;
};
-} // namespace server
-} // namespace ingen
+} // namespace ingen::server
#endif // INGEN_ENGINE_PREPROCESSOR_HPP