*
* 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.
*
{
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));
}
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) {
* 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)
* @queue: a #GstAtomicQueue
*
* Increase the refcount of @queue.
- *
- * Since: 0.10.33
*/
void
gst_atomic_queue_ref (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)
*
* 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)
/* 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;
*
* 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)
/* 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;
* @data: the data
*
* Append @data to the tail of the queue.
- *
- * Since: 0.10.33
*/
void
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
* 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)