Document glib hash table "replacement" behavior
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 3 Sep 2011 18:51:40 +0000 (14:51 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Sat, 3 Sep 2011 18:51:40 +0000 (14:51 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
tests/test_glib_hash.c

index 3559b2b88e28abbbe536d085eb1c3a6ca5587f61..37b1d32c3a07f68775a490c3dc2f64ba3ce55038 100644 (file)
@@ -414,17 +414,18 @@ void *thr_writer(void *_count)
                if (add_only || rand_r(&rand_lookup) & 1) {
                        node = malloc(1);
                        rcu_copy_mutex_lock();
-                       //if (add_unique)
-                       //      ret_node = ht_add_unique(test_ht, node);
-                       //else
+                       /* Glib hash table only supports replacement. */
+                       if (!add_unique) {
+                               add_unique = 1; /* force add_unique */
+                               printf("glib hash tables only supports "
+       "replacing values (and keys in addition) when the key to insert is already "
+       "present. Make sure you compare with the \"add_unique\" (-u) RCU hash table "
+       "behavior, which is the closest match.\n");
+                       }
                        g_hash_table_insert(test_ht,
                                (void *)(unsigned long)(rand_r(&rand_lookup) % rand_pool),
                                node);
                        rcu_copy_mutex_unlock();
-                       //if (add_unique && ret_node != node) {
-                       //      free(node);
-                       //      nr_addexist++;
-                       //} else
                        nr_add++;
                } else {
                        /* May delete */
This page took 0.025679 seconds and 4 git commands to generate.