summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2018-11-25 23:24:34 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2018-11-25 23:24:34 (GMT)
commitcb07198d95b9fa84474f624af0eda8ae97960a70 (patch)
treebdd9cb498857bd9ce5d8fa53395aea3769397a4c
parent0daafbb6b4c0e845f9e61a28adb0a68bb2d0b582 (diff)
Created a lock for collections.
-rw-r--r--src/core/collections.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/core/collections.c b/src/core/collections.c
index 2f28857..d045e5a 100644
--- a/src/core/collections.c
+++ b/src/core/collections.c
@@ -43,7 +43,7 @@ static GType *_collection_definitions = NULL;
static uint32_t _collection_definitions_count = 0;
/* Verrou pour des accès atomiques */
-/* ... */
+G_LOCK_DEFINE_STATIC(_collec_mutex);
@@ -63,7 +63,7 @@ uint32_t register_collection_type(GType items)
{
uint32_t result; /* Identifiant à retourner */
- /* TODO : lock */
+ G_LOCK(_collec_mutex);
result = _collection_definitions_count++;
@@ -72,7 +72,7 @@ uint32_t register_collection_type(GType items)
_collection_definitions[result] = items;
- /* TODO : unlock */
+ G_UNLOCK(_collec_mutex);
return result;
@@ -168,6 +168,8 @@ GList *create_collections_list(void)
result = NULL;
+ G_LOCK(_collec_mutex);
+
for (i = 0; i < _collection_definitions_count; i++)
{
collec = g_object_new(_collection_definitions[i], NULL);
@@ -176,6 +178,8 @@ GList *create_collections_list(void)
}
+ G_UNLOCK(_collec_mutex);
+
return result;
}