Go to the source code of this file.
|
struct | ring_queue |
| Represents a ring queue of a particular size. Does not resize dynamically. Naturally, this is a first in, first out structure. More...
|
|
|
typedef struct ring_queue | ring_queue |
| Represents a ring queue of a particular size. Does not resize dynamically. Naturally, this is a first in, first out structure. More...
|
|
|
b8 | ring_queue_create (u32 stride, u32 capacity, void *memory, ring_queue *out_queue) |
| Creates a new ring queue of the given capacity and stride. More...
|
|
void | ring_queue_destroy (ring_queue *queue) |
| Destroys the given queue. If memory was not passed in during creation, it is freed here. More...
|
|
b8 | ring_queue_enqueue (ring_queue *queue, void *value) |
| Adds value to queue, if space is available. More...
|
|
b8 | ring_queue_dequeue (ring_queue *queue, void *out_value) |
| Attempts to retrieve the next value from the provided queue. More...
|
|
b8 | ring_queue_peek (const ring_queue *queue, void *out_value) |
| Attempts to retrieve, but not remove, the next value in the queue, if not empty. More...
|
|
◆ ring_queue
Represents a ring queue of a particular size. Does not resize dynamically. Naturally, this is a first in, first out structure.
◆ ring_queue_create()
Creates a new ring queue of the given capacity and stride.
- Parameters
-
stride | The size of each element in bytes. |
capacity | The total number of elements to be available in the queue. |
memory | The memory block used to hold the data. Should be the size of stride * capacity. If 0 is passed, a block is automatically allocated and freed upon creation/destruction. |
out_queue | A pointer to hold the newly created queue. |
- Returns
- True on success; otherwise false.
◆ ring_queue_dequeue()
b8 ring_queue_dequeue |
( |
ring_queue * |
queue, |
|
|
void * |
out_value |
|
) |
| |
Attempts to retrieve the next value from the provided queue.
- Parameters
-
queue | A pointer to the queue to retrieve data from. |
out_value | A pointer to hold the retrieved value. |
- Returns
- True if success; otherwise false.
◆ ring_queue_destroy()
Destroys the given queue. If memory was not passed in during creation, it is freed here.
- Parameters
-
queue | A pointer to the queue to destroy. |
◆ ring_queue_enqueue()
Adds value to queue, if space is available.
- Parameters
-
queue | A pointer to the queue to add data to. |
value | The value to be added. |
- Returns
- True if success; otherwise false.
◆ ring_queue_peek()
b8 ring_queue_peek |
( |
const ring_queue * |
queue, |
|
|
void * |
out_value |
|
) |
| |
Attempts to retrieve, but not remove, the next value in the queue, if not empty.
- Parameters
-
queue | A constant pointer to the queue to retrieve data from. |
out_value | A pointer to hold the retrieved value. |
- Returns
- True if success; otherwise false.