Loading...
Searching...
No Matches
it_q.h
Go to the documentation of this file.
#pragma once
#include <osmocom/core/linuxlist.h>
#include <osmocom/core/select.h>
#include <pthread.h>
struct osmo_it_q {
/* entry in global list of message queues */
struct llist_head entry;
/* the actual list of user structs. HEAD: first in queue; TAIL: last in queue */
struct llist_head list;
/* A pthread mutex to safeguard accesses to the queue. No rwlock as we always write. */
pthread_mutex_t mutex;
/* Current count of messages in the queue */
unsigned int current_length;
/* osmo-fd wrapped eventfd */
struct osmo_fd event_ofd;
/* a user-defined name for this queue */
const char *name;
/* maximum permitted length of queue */
unsigned int max_length;
/* read call-back, called for each de-queued message */
void (*read_cb)(struct osmo_it_q *q, struct llist_head *item);
/* opaque data pointer passed through to call-back function */
void *data;
};
struct osmo_it_q *osmo_it_q_by_name(const char *name);
int _osmo_it_q_enqueue(struct osmo_it_q *queue, struct llist_head *item);
#define osmo_it_q_enqueue(queue, item, member) \
_osmo_it_q_enqueue(queue, &(item)->member)
struct llist_head *_osmo_it_q_dequeue(struct osmo_it_q *queue);
#define osmo_it_q_dequeue(queue, item, member) do { \
struct llist_head *l = _osmo_it_q_dequeue(queue); \
if (!l) \
*item = NULL; \
else \
*item = llist_entry(l, typeof(**item), member); \
} while (0)
struct osmo_it_q *osmo_it_q_alloc(void *ctx, const char *name, unsigned int max_length,
void (*read_cb)(struct osmo_it_q *q, struct llist_head *item),
void *data);
void osmo_it_q_destroy(struct osmo_it_q *q);
void osmo_it_q_flush(struct osmo_it_q *q);
osmo_it_q_alloc
struct osmo_it_q * osmo_it_q_alloc(void *ctx, const char *name, unsigned int max_length, void(*read_cb)(struct osmo_it_q *q, struct llist_head *item), void *data)
osmo_it_q_by_name
struct osmo_it_q * osmo_it_q_by_name(const char *name)
osmo_it_q_destroy
void osmo_it_q_destroy(struct osmo_it_q *q)
_osmo_it_q_enqueue
int _osmo_it_q_enqueue(struct osmo_it_q *queue, struct llist_head *item)
osmo_it_q_flush
void osmo_it_q_flush(struct osmo_it_q *q)
_osmo_it_q_dequeue
struct llist_head * _osmo_it_q_dequeue(struct osmo_it_q *queue)
name
char name[32]
source file name
Definition gsmtap.h:11
linuxlist.h
Simple doubly linked list implementation.
select.h
libmnl integration
llist_head
(double) linked list header structure
Definition linuxlist.h:46
osmo_fd
Structure representing a file dsecriptor.
Definition select.h:31
osmo_it_q
One instance of an inter-thread queue.
Definition it_q.h:16
osmo_it_q::entry
struct llist_head entry
Definition it_q.h:18
osmo_it_q::event_ofd
struct osmo_fd event_ofd
Definition it_q.h:27
osmo_it_q::data
void * data
Definition it_q.h:36
osmo_it_q::max_length
unsigned int max_length
Definition it_q.h:32
osmo_it_q::list
struct llist_head list
Definition it_q.h:21
osmo_it_q::current_length
unsigned int current_length
Definition it_q.h:25
osmo_it_q::name
const char * name
Definition it_q.h:30
osmo_it_q::read_cb
void(* read_cb)(struct osmo_it_q *q, struct llist_head *item)
Definition it_q.h:34
osmo_it_q::mutex
pthread_mutex_t mutex
Definition it_q.h:23