summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-10-14 21:48:08 -0400
committerDavid Robillard <d@drobilla.net>2016-10-14 21:48:08 -0400
commit843d59675dbb4baecbc09712e5c020dfcc5f09df (patch)
tree76f923f90d59bd4dd769ec516c7aba11b8f6e635 /src
parentc7c64abd524911ee8bf3e2be9d8aec38b1b4d18a (diff)
downloadingen-843d59675dbb4baecbc09712e5c020dfcc5f09df.tar.gz
ingen-843d59675dbb4baecbc09712e5c020dfcc5f09df.tar.bz2
ingen-843d59675dbb4baecbc09712e5c020dfcc5f09df.zip
Fix occasionally stuck event queue
Diffstat (limited to 'src')
-rw-r--r--src/server/PreProcessor.cpp21
-rw-r--r--src/server/PreProcessor.hpp1
2 files changed, 13 insertions, 9 deletions
diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp
index 1fd02cf3..c23c99d6 100644
--- a/src/server/PreProcessor.cpp
+++ b/src/server/PreProcessor.cpp
@@ -38,7 +38,6 @@ PreProcessor::PreProcessor(Engine& engine)
: _engine(engine)
, _sem(0)
, _head(NULL)
- , _prepared_back(NULL)
, _tail(NULL)
, _block_state(BlockState::UNBLOCKED)
, _exit_flag(false)
@@ -76,10 +75,6 @@ PreProcessor::event(Event* const ev, Event::Mode mode)
_tail = ev;
}
- if (!_prepared_back.load()) {
- _prepared_back = ev;
- }
-
_sem.post();
}
@@ -169,14 +164,24 @@ PreProcessor::run()
_engine.world()->uri_map(), _engine.world()->uris(), redo_stack);
ThreadManager::set_flag(THREAD_PRE_PROCESS);
+
+ Event* back = NULL;
while (!_exit_flag) {
if (!_sem.timed_wait(1000)) {
continue;
}
- Event* const ev = _prepared_back.load();
+ if (!back) {
+ // Ran off end, find new unprepared back
+ back = _head;
+ while (back && back->is_prepared()) {
+ back = back->next();
+ }
+ }
+
+ Event* const ev = back;
if (!ev) {
- return;
+ continue;
}
assert(!ev->is_prepared());
@@ -214,7 +219,7 @@ PreProcessor::run()
_block_state = BlockState::PRE_UNBLOCKED;
}
- _prepared_back = (Event*)ev->next();
+ back = (Event*)ev->next();
}
}
diff --git a/src/server/PreProcessor.hpp b/src/server/PreProcessor.hpp
index 5dc7bef0..61598ee0 100644
--- a/src/server/PreProcessor.hpp
+++ b/src/server/PreProcessor.hpp
@@ -69,7 +69,6 @@ private:
std::mutex _mutex;
Raul::Semaphore _sem;
std::atomic<Event*> _head;
- std::atomic<Event*> _prepared_back;
std::atomic<Event*> _tail;
std::atomic<BlockState> _block_state;
bool _exit_flag;