implement ui_queue_free

Sun, 07 Dec 2025 10:51:47 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 07 Dec 2025 10:51:47 +0100
changeset 955
ea9a999b4fc8
parent 954
07c1effb2a31
child 956
4cdfbfd2038d

implement ui_queue_free

application/main.c file | annotate | diff | comparison | revisions
ui/common/threadpool.c file | annotate | diff | comparison | revisions
--- a/application/main.c	Sun Dec 07 10:41:04 2025 +0100
+++ b/application/main.c	Sun Dec 07 10:51:47 2025 +0100
@@ -213,6 +213,8 @@
 static int thr_end = 0;
 static int thr_started = 0;
 
+static UiThreadpool *threadpool;
+
 int threadfunc(void *data) {
     printf("thr wait for data...\n");
     ui_condvar_wait(cond);
@@ -900,6 +902,8 @@
     ui_toolbar_add_default("Test4", UI_TOOLBAR_RIGHT);
     ui_toolbar_add_default("Test5", UI_TOOLBAR_RIGHT);
     
+    threadpool = ui_threadpool_create(10);
+    
     ui_main();
     
     return (EXIT_SUCCESS);
--- a/ui/common/threadpool.c	Sun Dec 07 10:41:04 2025 +0100
+++ b/ui/common/threadpool.c	Sun Dec 07 10:51:47 2025 +0100
@@ -156,7 +156,12 @@
 }
 
 void ui_queue_free(UiQueue *queue) {
-    // TODO
+    // The queue must be empty, we could free UiQueueElm,
+    // but not the payload data
+    pthread_mutex_destroy(&queue->lock);
+    pthread_mutex_destroy(&queue->avlbl_lock);
+    pthread_cond_destroy(&queue->available);
+    free(queue);
 }
 
 void ui_queue_put(UiQueue *queue, void *data) {

mercurial