The FreeRADIUS server
$Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
|
Thread-safe queues. More...
#include <stdint.h>
#include <stdalign.h>
#include <inttypes.h>
#include <freeradius-devel/autoconf.h>
#include <freeradius-devel/io/atomic_queue.h>
#include <freeradius-devel/util/talloc.h>
Go to the source code of this file.
Data Structures | |
struct | fr_atomic_queue_entry_t |
Entry in the queue. More... | |
struct | fr_atomic_queue_s |
Structure to hold the atomic queue. More... | |
Macros | |
#define | CACHE_LINE_SIZE 64 |
Functions | |
fr_atomic_queue_t * | fr_atomic_queue_alloc (TALLOC_CTX *ctx, size_t size) |
Create fixed-size atomic queue. More... | |
void | fr_atomic_queue_debug (fr_atomic_queue_t *aq, FILE *fp) |
Dump an atomic queue. More... | |
void | fr_atomic_queue_free (fr_atomic_queue_t **aq) |
Free an atomic queue if it's not freed by ctx. More... | |
bool | fr_atomic_queue_pop (fr_atomic_queue_t *aq, void **p_data) |
Pop a pointer from the atomic queue. More... | |
bool | fr_atomic_queue_push (fr_atomic_queue_t *aq, void *data) |
Push a pointer into the atomic queue. More... | |
size_t | fr_atomic_queue_size (fr_atomic_queue_t *aq) |
Thread-safe queues.
Definition in file atomic_queue.c.
struct fr_atomic_queue_entry_t |
Entry in the queue.
Definition at line 44 of file atomic_queue.c.
Data Fields | ||
---|---|---|
void * | data | |
atomic_int64_t | seq | Must be seq then data to ensure seq is 64bit aligned for 32bit address spaces. |
struct fr_atomic_queue_s |
Structure to hold the atomic queue.
Definition at line 54 of file atomic_queue.c.
Data Fields | ||
---|---|---|
void * | chunk | To pass to free. The non-aligned address. |
fr_atomic_queue_entry_t | entry[] | The entry array, also aligned to ensure it's not in the same cache line as tail and size. |
atomic_int64_t | head | Head, aligned bytes to ensure it's in a different cache line to tail to reduce memory contention. |
size_t | size | |
atomic_int64_t | tail |
#define CACHE_LINE_SIZE 64 |
Definition at line 36 of file atomic_queue.c.
fr_atomic_queue_t* fr_atomic_queue_alloc | ( | TALLOC_CTX * | ctx, |
size_t | size | ||
) |
Create fixed-size atomic queue.
[in] | ctx | The talloc ctx to allocate the queue in. |
[in] | size | The number of entries in the queue. |
Definition at line 80 of file atomic_queue.c.
void fr_atomic_queue_debug | ( | fr_atomic_queue_t * | aq, |
FILE * | fp | ||
) |
Dump an atomic queue.
Absolutely NOT thread-safe.
[in] | aq | The atomic queue to debug. |
[in] | fp | where the debugging information will be printed. |
Definition at line 301 of file atomic_queue.c.
void fr_atomic_queue_free | ( | fr_atomic_queue_t ** | aq | ) |
Free an atomic queue if it's not freed by ctx.
This function is needed because the atomic queue memory must be cache line aligned.
Definition at line 132 of file atomic_queue.c.
bool fr_atomic_queue_pop | ( | fr_atomic_queue_t * | aq, |
void ** | p_data | ||
) |
Pop a pointer from the atomic queue.
[in] | aq | the atomic queue to retrieve data from. |
[out] | p_data | where to write the data. |
Definition at line 215 of file atomic_queue.c.
bool fr_atomic_queue_push | ( | fr_atomic_queue_t * | aq, |
void * | data | ||
) |
Push a pointer into the atomic queue.
[in] | aq | The atomic queue to add data to. |
[in] | data | to push. |
Definition at line 148 of file atomic_queue.c.
size_t fr_atomic_queue_size | ( | fr_atomic_queue_t * | aq | ) |