Skip to content

Commit 038c620

Browse files
committed
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
1 parent 7e96c98 commit 038c620

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

extras/threadedProcessing.ec

+5-2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class ProcessingStage
5656
bool result = false;
5757
ProcessingTask task;
5858

59+
mutex.Wait();
5960
if(!thread)
6061
{
6162
thread = threads[0];
@@ -68,7 +69,6 @@ class ProcessingStage
6869

6970
// PrintLn("Thread ", thread.number, " working!");
7071

71-
mutex.Wait();
7272
task = tasks.first;
7373
if(task)
7474
{
@@ -285,7 +285,10 @@ class ProcessingStage
285285
{
286286
semaphore.Release();
287287
t.Wait();
288-
delete threads[i];
288+
mutex.Wait();
289+
delete t;
290+
threads[i] = null;
291+
mutex.Release();
289292
}
290293
}
291294
threads.size = 1;

0 commit comments

Comments
 (0)