From ab705b2c7fedce89ff08b36195706b2a1d9e1c42 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sun, 25 Aug 2024 19:04:01 +0200
Subject: Mark 0 as a reserved work group identifier.

---
 src/glibext/workgroup.h | 5 +++++
 src/glibext/workqueue.c | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/glibext/workgroup.h b/src/glibext/workgroup.h
index 1a003c8..f40155e 100644
--- a/src/glibext/workgroup.h
+++ b/src/glibext/workgroup.h
@@ -47,6 +47,11 @@ DECLARE_GTYPE(GWorkGroup, g_work_group, G, WORK_GROUP);
  */
 typedef uint64_t wgroup_id_t;
 
+/**
+ * Marque de non initialisation.
+ */
+#define INVALID_GROUP_ID 0
+
 
 /* Crée un nouveau thread dédié à un type de travaux donné. */
 GWorkGroup *g_work_group_new(wgroup_id_t, guint);
diff --git a/src/glibext/workqueue.c b/src/glibext/workqueue.c
index ad6ede6..fe7f1bb 100644
--- a/src/glibext/workqueue.c
+++ b/src/glibext/workqueue.c
@@ -247,8 +247,13 @@ wgroup_id_t g_work_queue_define_group(GWorkQueue *queue, guint count)
 
     do
     {
-        result = queue->generator++;
+        result = ++queue->generator;
+
+        if (result == INVALID_GROUP_ID)
+            continue;
+
         created = g_work_queue_ensure_group_exists(queue, result, count);
+
     }
     while (!created);
 
-- 
cgit v0.11.2-87-g4458