From eef91c0cf7c17bf526c96c3eea2de65427aed237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petar=20Kapri=C5=A1?= Date: Fri, 24 Oct 2025 09:52:36 +0200 Subject: [PATCH] Edit description of concurrency model --- mandelbrot-visualizer.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mandelbrot-visualizer.c b/mandelbrot-visualizer.c index 14a57ae..e5be50c 100644 --- a/mandelbrot-visualizer.c +++ b/mandelbrot-visualizer.c @@ -30,15 +30,24 @@ struct threadInfo { /* * Concurrency model explained: - * One reader thread (the GUI thread) of the pixel buffer, along with many - * writers, who split the work of rendering roughly equally. The writers don't - * do any work until the pixel map which they are meant to work on is marked as - * available. + * One main thread, along with many workers in a thread pool, who split the work of + * rendering roughly equally. The writers don't do any work until the pixel map which they + * are meant to work on is marked as available, and they are all singalled to start + * drawing. * * Once it is marked as such, this means that the planeView structure is well * defined, that pixmap points to a memory region, which is allocated with * enough memory for the plain view, and they can all start writing without an * issue. + * + * Once they are all finished, the last thread to exit the drawing function will signal + * the main thread to "blit" the finished image to the screen. + * + * If any kind of change by the user happens (window resize, panning/zooming (TODO: not + * implemented yet), the main thread will cause all worker threads to stop working, if + * they haven't already (they occassionally poll while drawing to see if they should + * stop). Once they've all stopped, the main thread will update and replace the drawing + * area, and naturally, signal them to start drawing again. */ pthread_mutex_t pixmapMutex;