Revert "meson: Force gstenum_h to be built when using gst_dep"
[platform/upstream/gstreamer.git] / gst / gstatomicqueue.c
index e7bfcca..a80089c 100644 (file)
@@ -16,8 +16,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 #include "gst_private.h"
  *
  * The #GstAtomicQueue object implements a queue that can be used from multiple
  * threads without performing any blocking operations.
- *
- * Since: 0.10.33
  */
 
+G_DEFINE_BOXED_TYPE (GstAtomicQueue, gst_atomic_queue,
+    (GBoxedCopyFunc) gst_atomic_queue_ref,
+    (GBoxedFreeFunc) gst_atomic_queue_unref);
+
 /* By default the queue uses 2 * sizeof(gpointer) * clp2 (max_items) of
  * memory. clp2(x) is the next power of two >= than x.
  *
@@ -115,7 +117,7 @@ add_to_free_list (GstAtomicQueue * queue, GstAQueueMem * mem)
 {
   do {
     mem->free = g_atomic_pointer_get (&queue->free_list);
-  } while (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->free_list,
+  } while (!g_atomic_pointer_compare_and_exchange (&queue->free_list,
           mem->free, mem));
 }
 
@@ -129,7 +131,7 @@ clear_free_list (GstAtomicQueue * queue)
     free_list = g_atomic_pointer_get (&queue->free_list);
     if (free_list == NULL)
       return;
-  } while (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->free_list, free_list,
+  } while (!g_atomic_pointer_compare_and_exchange (&queue->free_list, free_list,
           NULL));
 
   while (free_list) {
@@ -149,8 +151,6 @@ clear_free_list (GstAtomicQueue * queue)
  * nearest power of 2 and used as the initial size of the queue.
  *
  * Returns: a new #GstAtomicQueue
- *
- * Since: 0.10.33
  */
 GstAtomicQueue *
 gst_atomic_queue_new (guint initial_size)
@@ -174,8 +174,6 @@ gst_atomic_queue_new (guint initial_size)
  * @queue: a #GstAtomicQueue
  *
  * Increase the refcount of @queue.
- *
- * Since: 0.10.33
  */
 void
 gst_atomic_queue_ref (GstAtomicQueue * queue)
@@ -200,8 +198,6 @@ gst_atomic_queue_free (GstAtomicQueue * queue)
  * @queue: a #GstAtomicQueue
  *
  * Unref @queue and free the memory when the refcount reaches 0.
- *
- * Since: 0.10.33
  */
 void
 gst_atomic_queue_unref (GstAtomicQueue * queue)
@@ -218,9 +214,8 @@ gst_atomic_queue_unref (GstAtomicQueue * queue)
  *
  * Peek the head element of the queue without removing it from the queue.
  *
- * Returns: the head element of @queue or NULL when the queue is empty.
- *
- * Since: 0.10.33
+ * Returns: (transfer none) (nullable): the head element of @queue or
+ * %NULL when the queue is empty.
  */
 gpointer
 gst_atomic_queue_peek (GstAtomicQueue * queue)
@@ -250,7 +245,7 @@ gst_atomic_queue_peek (GstAtomicQueue * queue)
 
     /* now we try to move the next array as the head memory. If we fail to do that,
      * some other reader managed to do it first and we retry */
-    if (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->head_mem, head_mem,
+    if (!g_atomic_pointer_compare_and_exchange (&queue->head_mem, head_mem,
             next))
       continue;
 
@@ -269,9 +264,8 @@ gst_atomic_queue_peek (GstAtomicQueue * queue)
  *
  * Get the head element of the queue.
  *
- * Returns: the head element of @queue or NULL when the queue is empty.
- *
- * Since: 0.10.33
+ * Returns: (transfer full): the head element of @queue or %NULL when
+ * the queue is empty.
  */
 gpointer
 gst_atomic_queue_pop (GstAtomicQueue * queue)
@@ -309,7 +303,7 @@ gst_atomic_queue_pop (GstAtomicQueue * queue)
       /* now we try to move the next array as the head memory. If we fail to do that,
        * some other reader managed to do it first and we retry */
       if G_UNLIKELY
-        (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->head_mem, head_mem,
+        (!g_atomic_pointer_compare_and_exchange (&queue->head_mem, head_mem,
                 next))
             continue;
 
@@ -339,8 +333,6 @@ gst_atomic_queue_pop (GstAtomicQueue * queue)
  * @data: the data
  *
  * Append @data to the tail of the queue.
- *
- * Since: 0.10.33
  */
 void
 gst_atomic_queue_push (GstAtomicQueue * queue, gpointer data)
@@ -369,7 +361,7 @@ gst_atomic_queue_push (GstAtomicQueue * queue, gpointer data)
 
       /* try to make our new array visible to other writers */
       if G_UNLIKELY
-        (!G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE (&queue->tail_mem, tail_mem,
+        (!g_atomic_pointer_compare_and_exchange (&queue->tail_mem, tail_mem,
                 mem)) {
         /* we tried to swap the new writer array but something changed. This is
          * because some other writer beat us to it, we free our memory and try
@@ -403,8 +395,6 @@ gst_atomic_queue_push (GstAtomicQueue * queue, gpointer data)
  * Get the amount of items in the queue.
  *
  * Returns: the number of elements in the queue.
- *
- * Since: 0.10.33
  */
 guint
 gst_atomic_queue_length (GstAtomicQueue * queue)