diff options
Diffstat (limited to 'src/server/PreProcessor.cpp')
-rw-r--r-- | src/server/PreProcessor.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/server/PreProcessor.cpp b/src/server/PreProcessor.cpp index 83215bee..aa4f0b06 100644 --- a/src/server/PreProcessor.cpp +++ b/src/server/PreProcessor.cpp @@ -39,9 +39,11 @@ PreProcessor::PreProcessor() PreProcessor::~PreProcessor() { - _exit_flag = true; - _sem.post(); - _thread.join(); + if (_thread.joinable()) { + _exit_flag = true; + _sem.post(); + _thread.join(); + } } void @@ -71,18 +73,13 @@ PreProcessor::event(Event* const ev) } unsigned -PreProcessor::process(ProcessContext& context, PostProcessor& dest, bool limit) +PreProcessor::process(ProcessContext& context, PostProcessor& dest, size_t limit) { Event* const head = _head.load(); if (!head) { return 0; } - /* Limit the maximum number of events to process each cycle to ensure the - process callback is real-time safe. TODO: Parameterize this and/or - figure out a good default value. */ - const size_t MAX_EVENTS_PER_CYCLE = context.nframes() / 4; - size_t n_processed = 0; Event* ev = head; Event* last = ev; @@ -95,7 +92,7 @@ PreProcessor::process(ProcessContext& context, PostProcessor& dest, bool limit) last = ev; ev = ev->next(); ++n_processed; - if (limit && (n_processed > MAX_EVENTS_PER_CYCLE)) { + if (limit && n_processed >= limit) { break; } } |