[svn-commits] mmichelson: branch mmichelson/ao2_containers r165037 - /team/mmichelson/ao2_c...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 16 18:13:00 CST 2008


Author: mmichelson
Date: Tue Dec 16 18:13:00 2008
New Revision: 165037

URL: http://svn.digium.com/view/asterisk?view=rev&rev=165037
Log:
Add a large note above skiplist_iterator_next explaining
why this is the main hurdle of this branch. It really probably
won't matter though since I've decided that in the interest
of expediency, I won't be adding a skip list container.


Modified:
    team/mmichelson/ao2_containers/main/astobj2_skiplist.c

Modified: team/mmichelson/ao2_containers/main/astobj2_skiplist.c
URL: http://svn.digium.com/view/asterisk/team/mmichelson/ao2_containers/main/astobj2_skiplist.c?view=diff&rev=165037&r1=165036&r2=165037
==============================================================================
--- team/mmichelson/ao2_containers/main/astobj2_skiplist.c (original)
+++ team/mmichelson/ao2_containers/main/astobj2_skiplist.c Tue Dec 16 18:13:00 2008
@@ -190,7 +190,39 @@
 	return ret;
 }
 
-/* Complete this once iterator stuff is accomplished */
+/* XXX It is this cursed function that is preventing me from
+ * actually implementing a skip list for astobj2.
+ *
+ * The problem is that the items in the skip list are ordered
+ * based on a user-supplied comparison function. As opposed to
+ * other implementations, where the order in which the items
+ * were added has some bearing on the order.
+ *
+ * With hash tables, the items within a bucket are stored
+ * in the order in which they were added.
+ *
+ * With linked lists, the items are stored in the order they
+ * were added.
+ *
+ * Why does this matter? It matters because the iterator must
+ * be able to find its place in the container again for all 
+ * subsequent calls to this function. The problem is that in 
+ * a multi-threaded environment, the container may be modified 
+ * while we are iterating the skip list
+ *
+ * The other container implementations find their place again by
+ * checking the container "version" stored in the iterator and 
+ * compare this to the "version" of the container. If they differ, 
+ * then they need to adjust appropriately by finding an object 
+ * with a version number higher than the version of the object 
+ * they were just examining.
+ *
+ * Because of the ordering of skip lists, it makes it very hard
+ * to make sure that all items in the skip list have ascending
+ * version numbers. If nothing else, adding the code to do this
+ * would be complex and completely take away from the efficiency
+ * gains that are supposed to be had with skip lists.
+ */
 static void *skiplist_iterator_next(struct ao2_iterator *a)
 {
 	struct skiplist_pvt *skip_pvt = a->c->private;




More information about the svn-commits mailing list