Fix: add missing destroy functions to queues/stack APIs
[urcu.git] / urcu / static / lfstack.h
index 77a26dc39293e0a230d00688cbd786e9dab32db0..967071a0cffcf74ba86465362efb7ae1fb17514f 100644 (file)
@@ -8,8 +8,8 @@
  *
  * Copyright 2010-2012 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See rculfstack.h for linking
- * dynamically with the userspace rcu library.
+ * TO BE INCLUDED ONLY IN LGPL-COMPATIBLE CODE. See urcu/lfstack.h for
+ * linking dynamically with the userspace rcu library.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -66,7 +66,8 @@ void _cds_lfs_node_init(struct cds_lfs_node *node)
 }
 
 /*
- * cds_lfs_init: initialize lock-free stack.
+ * cds_lfs_init: initialize lock-free stack (with lock). Pair with
+ * cds_lfs_destroy().
  */
 static inline
 void _cds_lfs_init(struct cds_lfs_stack *s)
@@ -78,6 +79,17 @@ void _cds_lfs_init(struct cds_lfs_stack *s)
        assert(!ret);
 }
 
+/*
+ * cds_lfs_destroy: destroy lock-free stack (with lock). Pair with
+ * cds_lfs_init().
+ */
+static inline
+void _cds_lfs_destroy(struct cds_lfs_stack *s)
+{
+        int ret = pthread_mutex_destroy(&s->lock);
+       assert(!ret);
+}
+
 static inline
 bool ___cds_lfs_empty_head(struct cds_lfs_head *head)
 {
@@ -118,7 +130,7 @@ bool _cds_lfs_empty(struct cds_lfs_stack *s)
  * always performing an exclusive cacheline access, rather than doing
  * non-exclusive followed by exclusive cacheline access (which would be
  * required if we first read the old head value). This design decision
- * might be revisited after more throrough benchmarking on various
+ * might be revisited after more thorough benchmarking on various
  * platforms.
  *
  * Returns 0 if the stack was empty prior to adding the node.
@@ -148,7 +160,7 @@ bool _cds_lfs_push(struct cds_lfs_stack *s,
                if (old_head == head)
                        break;
        }
-       return ___cds_lfs_empty_head(head);
+       return !___cds_lfs_empty_head(head);
 }
 
 /*
This page took 0.024427 seconds and 4 git commands to generate.