GstAtomic

GstAtomic — Functions that implement atomic operations.

Synopsis


#include <gst/gst.h>


typedef     gst_vgint;
struct      GstAtomicInt;
void        gst_atomic_int_init             (GstAtomicInt *aint,
                                             gint val);
void        gst_atomic_int_destroy          (GstAtomicInt *aint);
void        gst_atomic_int_set              (GstAtomicInt *aint,
                                             gint val);
gint        gst_atomic_int_read             (GstAtomicInt *aint);
void        gst_atomic_int_add              (GstAtomicInt *aint,
                                             gint val);
void        gst_atomic_int_inc              (GstAtomicInt *aint);
gboolean    gst_atomic_int_dec_and_test     (GstAtomicInt *aint);

Description

Functions that implement atomic operations on a GstAtomicInt structure. Atomic operations are thread safe and don't use heavyweight locking mechanisms.

These functions will be inlined in the GStreamer core but are available to plugins as external methods.

Details

gst_vgint

typedef volatile gint gst_vgint;	/* gtk-doc volatile workaround */


struct GstAtomicInt

struct GstAtomicInt {

  gst_vgint     counter;
  GMutex	*lock;		/* for C fallback */
};

A structure that contains an integer that can be modified atomically.


gst_atomic_int_init ()

void        gst_atomic_int_init             (GstAtomicInt *aint,
                                             gint val);

Initialize an allocated GstAtomicInt with a value. Call this method only once as it will allocate a mutex in the C-fallback case.

aint :a GstAtomicInt
val :a new value

gst_atomic_int_destroy ()

void        gst_atomic_int_destroy          (GstAtomicInt *aint);

Destroy a GstAtomicInt. Call this method only once as it will free the mutex in the C-fallback case.

aint :a GstAtomicInt

gst_atomic_int_set ()

void        gst_atomic_int_set              (GstAtomicInt *aint,
                                             gint val);

Atomically set the value on the GstAtomicInt.

aint :a GstAtomicInt
val :The new value

gst_atomic_int_read ()

gint        gst_atomic_int_read             (GstAtomicInt *aint);

Atomically read the contents of a GstAtomicInt

aint :a GstAtomicInt
Returns :the value of the atomic int

gst_atomic_int_add ()

void        gst_atomic_int_add              (GstAtomicInt *aint,
                                             gint val);

Atomically add the given value to the GstAtomicInt.

aint :a GstAtomicInt
val :the value to add

gst_atomic_int_inc ()

void        gst_atomic_int_inc              (GstAtomicInt *aint);

Atomically increment the GstAtomicInt

aint :a GstAtomicInt

gst_atomic_int_dec_and_test ()

gboolean    gst_atomic_int_dec_and_test     (GstAtomicInt *aint);

Atomically decrement the GstAtomicInt and test if it is zero.

aint :a GstAtomicInt
Returns :TRUE if the atomic int is 0

See Also

GstMemChunk