From 09bdf20aa0a6e29265e5e7b81b941a2b894be3db Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Mon, 13 Jul 2020 13:27:23 +0200 Subject: render: keep lock while pushing dirty rows to worker queue Instead of locking the queue for each dirty row we append, and signaling a condition variable, just keep the lock while going through the visible rows. Release the lock once done. Since we take the lock *before* posting the 'start' semaphore, all workers will be waiting for the lock to be released. Then, one at a time they'll get the lock and pick a row to render. The queue will never get empty - when all rows have been rendered, each worker will pick a 'frame done' "job" from the queue, and break the rendering loop. --- terminal.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index a97685c6..3a679b5d 100644 --- a/terminal.c +++ b/terminal.c @@ -507,13 +507,6 @@ initialize_render_workers(struct terminal *term) goto err_sem_destroy; } - if ((err = cnd_init(&term->render.workers.cond)) != thrd_success) { - LOG_ERR( - "failed to instantiate render worker condition variable: %s (%d)", - thrd_err_as_string(err), err); - goto err_sem_destroy; - } - term->render.workers.threads = calloc( term->render.workers.count, sizeof(term->render.workers.threads[0])); @@ -1165,7 +1158,6 @@ term_destroy(struct terminal *term) sem_post(&term->render.workers.start); tll_push_back(term->render.workers.queue, -2); } - cnd_broadcast(&term->render.workers.cond); } mtx_unlock(&term->render.workers.lock); @@ -1198,7 +1190,6 @@ term_destroy(struct terminal *term) } } free(term->render.workers.threads); - cnd_destroy(&term->render.workers.cond); mtx_destroy(&term->render.workers.lock); sem_destroy(&term->render.workers.start); sem_destroy(&term->render.workers.done); -- cgit v1.3