summaryrefslogtreecommitdiffstats
path: root/src/libs/engine/PostProcessor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/engine/PostProcessor.cpp')
-rw-r--r--src/libs/engine/PostProcessor.cpp90
1 files changed, 12 insertions, 78 deletions
diff --git a/src/libs/engine/PostProcessor.cpp b/src/libs/engine/PostProcessor.cpp
index e339f757..8b68159e 100644
--- a/src/libs/engine/PostProcessor.cpp
+++ b/src/libs/engine/PostProcessor.cpp
@@ -29,94 +29,28 @@ using std::cerr; using std::cout; using std::endl;
namespace Om {
-bool PostProcessor::m_process_thread_exit_flag = false;
-
PostProcessor::PostProcessor(size_t queue_size)
-: m_events(queue_size),
- m_thread_exists(false),
- m_semaphore(0)
-{
-}
-
-
-PostProcessor::~PostProcessor()
-{
- stop();
-}
-
-
-/** Start the process thread.
- */
-void
-PostProcessor::start()
-{
- cout << "[PostProcessor] Starting." << endl;
-
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setstacksize(&attr, 1500000);
-
- pthread_create(&m_process_thread, &attr, process_events, this);
- m_thread_exists = true;
-}
-
-
-/** Stop the process thread.
- */
-void
-PostProcessor::stop()
+: _events(queue_size)
{
- if (m_thread_exists) {
- m_process_thread_exit_flag = true;
- pthread_cancel(m_process_thread);
- pthread_join(m_process_thread, NULL);
- m_thread_exists = false;
- }
+ set_name("PostProcessor");
}
-/** Signal the PostProcessor to process all pending events.
+/** Post processing thread.
+ *
+ * Infinite loop that waits on the semaphore and processes every enqueued
+ * event (to be signalled at the end of every process cycle).
*/
void
-PostProcessor::signal()
+PostProcessor::_signalled()
{
- m_semaphore.post();
-}
-
-
-void*
-PostProcessor::process_events(void* osc_processer)
-{
- PostProcessor* me = (PostProcessor*)osc_processer;
- return me->m_process_events();
-}
-
-
-/** OSC message processing thread.
- */
-void*
-PostProcessor::m_process_events()
-{
- Event* ev = NULL;
-
- while (true) {
- m_semaphore.wait();
-
- if (m_process_thread_exit_flag)
- break;
-
- while (!m_events.is_empty()) {
- ev = m_events.pop();
- assert(ev != NULL);
- ev->post_process();
- om->maid()->push(ev);
- }
+ while ( ! _events.is_empty()) {
+ Event* const ev = _events.pop();
+ assert(ev);
+ ev->post_process();
+ om->maid()->push(ev);
}
-
- cout << "[PostProcessor] Exiting post processor thread." << endl;
-
- return NULL;
}
} // namespace Om