QuickIO  0.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Typedefs | Functions
queue.h File Reference

Provides a multiple-producer, multiple-consumer queue. More...

#include "qev.h"

Go to the source code of this file.

Typedefs

typedef struct qev_queue qev_queue_t
 Yeah, I'm going to need you to go ahead and not touch this.
 

Functions

qev_queue_tqev_queue_new (guint32 size)
 Creates a new queue. More...
 
void qev_queue_free (qev_queue_t *q)
 Frees up the queue. More...
 
gboolean qev_queue_enqueue (qev_queue_t *q, void *thing)
 Adds thing to the queue. More...
 
gboolean qev_queue_enqueue_unlocked (qev_queue_t *q, void *thing)
 Adds thing to the queue in a non-thread-safe manner. More...
 
void * qev_queue_dequeue (qev_queue_t *q)
 Removes the next available thing from the queue. More...
 
void * qev_queue_dequeue_unlocked (qev_queue_t *q)
 Removes the next available thing from the queue in a non-thread-safe manner. More...
 
guint32 qev_queue_size (qev_queue_t *q)
 The number of items in the queue. More...
 

Detailed Description

Provides a multiple-producer, multiple-consumer queue.

Author
Andrew Stone andre.nosp@m.w@cl.nosp@m.ovar..nosp@m.com

Function Documentation

void* qev_queue_dequeue ( qev_queue_t q)

Removes the next available thing from the queue.

Parameters
qThe queue to get an item from
Returns
An item from the queue, or NULL if the queue is empty.
void* qev_queue_dequeue_unlocked ( qev_queue_t q)

Removes the next available thing from the queue in a non-thread-safe manner.

Note
This function SHOULD ONLY be used in cooperation with qev_queue_enqueue_unlocked from a single thread. If you choose to use it with the locked functions, be sure that nothing else is touching the queue before calling this.
Parameters
qThe queue to get an item from
Returns
An item from the queue, or NULL if the queue is empty.
gboolean qev_queue_enqueue ( qev_queue_t q,
void *  thing 
)

Adds thing to the queue.

Parameters
qThe queue to insert into.
thingThe thing to add.
Returns
If the item was inserted; this will only fail if the queue is full
gboolean qev_queue_enqueue_unlocked ( qev_queue_t q,
void *  thing 
)

Adds thing to the queue in a non-thread-safe manner.

Note
This function SHOULD ONLY be used in cooperation with qev_queue_dequeue_unlocked from a single thread. If you choose to use it with the locked functions, be sure that nothing else is touching the queue before calling this.
Parameters
qThe queue to insert into.
thingThe thing to add.
Returns
If the item was inserted; this will only fail if the queue is full
void qev_queue_free ( qev_queue_t q)

Frees up the queue.

Attention
If the queue is not empty, you're going to leak memory.
Parameters
qThe queue to release
qev_queue_t* qev_queue_new ( guint32  size)

Creates a new queue.

Parameters
sizeThe maximum size of the queue. MUST be a power of 2.
guint32 qev_queue_size ( qev_queue_t q)

The number of items in the queue.

Parameters
qThe queue to get the size of
Returns
The size of the queue