Replace mentions of "writer" threads with "worker" threads

This commit is contained in:
Petar Kapriš 2025-10-24 10:20:20 +02:00
parent b2249f6639
commit b5b2d09d43

View file

@ -31,7 +31,7 @@ struct threadInfo {
/* /*
* Concurrency model explained: * Concurrency model explained:
* One main thread, along with many workers in a thread pool, who split the work of * 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 * rendering roughly equally. The workers 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 * are meant to work on is marked as available, and they are all singalled to start
* drawing. * drawing.
* *
@ -84,7 +84,7 @@ void color_lookup(int *r, int *g, int *b, double mu);
// worker code // worker code
gboolean queue_redraw_plane(void *arg); gboolean queue_redraw_plane(void *arg);
void *writer_thread(void *arg) void *worker_thread(void *arg)
{ {
struct threadInfo *info = arg; struct threadInfo *info = arg;
while (true) { while (true) {
@ -121,7 +121,7 @@ void draw_mandelbrot(struct threadInfo *info)
pthread_mutex_unlock(&pixmapMutex); pthread_mutex_unlock(&pixmapMutex);
return; return;
// after this, the thread will again enter the // after this, the thread will again enter the
// loop in the writer_thread function, and // loop in the worker_thread function, and
// enter a wait state // enter a wait state
} }
pthread_mutex_unlock(&pixmapMutex); pthread_mutex_unlock(&pixmapMutex);
@ -259,7 +259,7 @@ int main(int argc, char **argv)
// integer, if the thread fails to start, it will simply be // integer, if the thread fails to start, it will simply be
// overwritten by the same value in the next run of the loop // overwritten by the same value in the next run of the loop
pthread_t id; pthread_t id;
if (pthread_create(&id, NULL, &writer_thread, &threads[count])) { if (pthread_create(&id, NULL, &worker_thread, &threads[count])) {
pthread_detach(id); pthread_detach(id);
fprintf(stderr, "Failed to create thread %d\n", i); fprintf(stderr, "Failed to create thread %d\n", i);
continue; continue;