- _execution_tokens -= wakeup;
-
- DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 signals %2\n", pthread_name(), wakeup));
-
- for (int i = 0; i < wakeup; i++) {
- _execution_sem.signal ();
- }
-
- while (to_run == 0) {
- _execution_tokens += 1;
- pthread_mutex_unlock (&_trigger_mutex);
- DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 goes to sleep\n", pthread_name()));
- _execution_sem.wait ();
- if (!_threads_active) {
- return true;
- }
- DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 is awake\n", pthread_name()));
- pthread_mutex_lock (&_trigger_mutex);
- if (_trigger_queue.size()) {
- to_run = _trigger_queue.back();
- _trigger_queue.pop_back();
- }
- }
- pthread_mutex_unlock (&_trigger_mutex);
-
- to_run->process();
- to_run->finish (_current_chain);
-
- DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 has finished run_one()\n", pthread_name()));
-
- return !_threads_active;
+ _execution_tokens -= wakeup;
+
+ DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 signals %2\n", pthread_name(), wakeup));
+
+ for (int i = 0; i < wakeup; i++) {
+ _execution_sem.signal ();
+ }
+
+ while (to_run == 0) {
+ _execution_tokens += 1;
+ pthread_mutex_unlock (&_trigger_mutex);
+ DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 goes to sleep\n", pthread_name()));
+ _execution_sem.wait ();
+ if (!_threads_active) {
+ return true;
+ }
+ DEBUG_TRACE (DEBUG::ProcessThreads, string_compose ("%1 is awake\n", pthread_name()));
+ pthread_mutex_lock (&_trigger_mutex);
+ if (_trigger_queue.size()) {
+ to_run = _trigger_queue.back();
+ _trigger_queue.pop_back();
+ }
+ }
+ pthread_mutex_unlock (&_trigger_mutex);
+
+ to_run->process();
+ to_run->finish (_current_chain);
+
+ DEBUG_TRACE(DEBUG::ProcessThreads, string_compose ("%1 has finished run_one()\n", pthread_name()));
+
+ return !_threads_active;