From 038c620b9f44422a8c7e64fcb9d34ffeb82c33e3 Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Tue, 12 Sep 2023 00:58:18 -0400 Subject: [PATCH] extras/threadedProcessing.ec: Fixed race condition - Fixed race condition on initial setup of processing stage thread - Also some attempts at clarifying remaining potential race conditions upon stage termination --- extras/threadedProcessing.ec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/extras/threadedProcessing.ec b/extras/threadedProcessing.ec index 279064dfcd..ffcf1776bc 100644 --- a/extras/threadedProcessing.ec +++ b/extras/threadedProcessing.ec @@ -56,6 +56,7 @@ class ProcessingStage bool result = false; ProcessingTask task; + mutex.Wait(); if(!thread) { thread = threads[0]; @@ -68,7 +69,6 @@ class ProcessingStage // PrintLn("Thread ", thread.number, " working!"); - mutex.Wait(); task = tasks.first; if(task) { @@ -285,7 +285,10 @@ class ProcessingStage { semaphore.Release(); t.Wait(); - delete threads[i]; + mutex.Wait(); + delete t; + threads[i] = null; + mutex.Release(); } } threads.size = 1;