| Iris Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#define IRIS_TYPE_QUEUE IrisQueueVTable; IrisQueue; GType iris_queue_get_type (void); IrisQueue* iris_queue_new (void); IrisQueue* iris_queue_ref (IrisQueue *queue); void iris_queue_unref (IrisQueue *queue); void iris_queue_push (IrisQueue *queue, gpointer data); gpointer iris_queue_pop (IrisQueue *queue); gpointer iris_queue_try_pop (IrisQueue *queue); gpointer iris_queue_timed_pop (IrisQueue *queue, GTimeVal *timeout); guint iris_queue_length (IrisQueue *queue);
IrisQueue is a queue abstraction for concurrent queues. The default implementation wraps GAsyncQueue which is a lock-based queue.
See also IrisLFQueue and IrisWSQueue.
typedef struct {
void (*push) (IrisQueue *queue, gpointer data);
gpointer (*pop) (IrisQueue *queue);
gpointer (*try_pop) (IrisQueue *queue);
gpointer (*timed_pop) (IrisQueue *queue, GTimeVal *timeout);
guint (*length) (IrisQueue *queue);
void (*dispose) (IrisQueue *queue);
} IrisQueueVTable;
IrisQueue* iris_queue_new (void);
Creates a new instance of IrisQueue.
The default implementation of IrisQueue is a lock-free queue that works well under highly concurrent scenarios.
Returns : |
The newly created IrisQueue instance. |
IrisQueue* iris_queue_ref (IrisQueue *queue);
Increases the reference count of queue atomically by one.
|
An IrisQueue |
Returns : |
the queue pointer.
|
void iris_queue_unref (IrisQueue *queue);
Atomically decreases the reference count of queue by one. If the
reference count reaches zero, the queue is destroyed and all its
allocated resources are freed.
|
An IrisQueue |
void iris_queue_push (IrisQueue *queue, gpointer data);
Enqueues a new pointer into the queue. The default implementation does this atomically and lock-free.
|
An IrisQueue |
|
a gpointer |
gpointer iris_queue_pop (IrisQueue *queue);
Dequeues the next item from the queue. The default implementation does this atomically and lock-free.
gpointer iris_queue_try_pop (IrisQueue *queue);
Tries to pop an item off of the queue. If no item is available, NULL is
returned.
gpointer iris_queue_timed_pop (IrisQueue *queue, GTimeVal *timeout);
Tries to pop an item off of the queue within before the specified time has passed.
guint iris_queue_length (IrisQueue *queue);
Retreives the length of the queue.
The default implementation does not use a fence since the length of a concurrent queue may not be the same between a read and a write anyway. This means that updates from other threads may not have propogated the cache lines to the host cpu (but in most cases, this is probably fine).
|
An IrisQueue |
Returns : |
the length of the queue. |