27RCSID(
"$Id: 9438d77eea3fafc3f2a3bb54cdc90a036fba9154 $")
 
   29#include <freeradius-devel/util/fring.h> 
   64        if (fring->
lock) pthread_mutex_destroy(&fring->
mutex);
 
 
   87        for (pow = 0x00000001;
 
   94        if (!fring) 
return NULL;
 
   97        fring->
data = talloc_zero_array(fring, 
void *, size);
 
  106                pthread_mutex_init(&fring->
mutex, NULL);
 
 
  123        if (fring->
lock) pthread_mutex_lock(&fring->
mutex);
 
  125        if (fring->
data[fring->
in]) {
 
  131        fring->
in = (fring->
in + 1) & fring->
size;
 
  134        if (fring->
in == fring->
out) fring->
out = (fring->
out + 1) & fring->
size;
 
  136        if (fring->
lock) pthread_mutex_unlock(&fring->
mutex);
 
  138        return freed ? 1 : 0;
 
 
  151        if (fring->
lock) pthread_mutex_lock(&fring->
mutex);
 
  153        if (fring->
data[fring->
in]) {
 
  154                if (fring->
lock) pthread_mutex_unlock(&fring->
mutex);
 
  160        fring->
in = (fring->
in + 1) & fring->
size;
 
  163        if (fring->
in == fring->
out) fring->
out = (fring->
out + 1) & fring->
size;
 
  165        if (fring->
lock) pthread_mutex_unlock(&fring->
mutex);
 
 
  181        if (fring->
lock) pthread_mutex_lock(&fring->
mutex);
 
  187        fring->
data[fring->
out] = NULL;
 
  191        if (fring->
lock) pthread_mutex_unlock(&fring->
mutex);
 
 
void const  * end
End of allocated memory.
bool lock
Perform thread synchronisation.
void ** data
Ring buffer data.
int fr_fring_overwrite(fr_fring_t *fring, void *in)
Insert a new item into the circular buffer, freeing the tail if we hit it.
void * fr_fring_next(fr_fring_t *fring)
Remove an item from the buffer.
pthread_mutex_t mutex
Thread synchronisation mutex.
int fr_fring_insert(fr_fring_t *fring, void *in)
Insert a new item into the circular buffer if the buffer is not full.
fr_fring_t * fr_fring_alloc(TALLOC_CTX *ctx, uint32_t size, bool lock)
Initialise a ring buffer with fixed element size.
static int _fring_free(fr_fring_t *fring)
Destroy mutex associated with ring buffer.
Standard thread safe circular buffer.
static size_t char ** out