Inter-Thread Queue

## Data Structures

struct | osmo_it_q
| One instance of an inter-thread queue. More...

## Macros

#define | osmo_it_q_enqueue(queue, item, member) _osmo_it_q_enqueue(queue, &(item)->member)
#define | osmo_it_q_dequeue(queue, item, member)

## Functions

struct osmo_it_q * | osmo_it_q_by_name (const char *name)
| resolve it-queue by its [globally unique] name More...
int | _osmo_it_q_enqueue (struct osmo_it_q *queue, struct llist_head *item)
| Thread-safe en-queue to an inter-thread message queue. More...
struct llist_head * | _osmo_it_q_dequeue (struct osmo_it_q *queue)
| Thread-safe de-queue from an inter-thread message queue. More...
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)
| Allocate a new inter-thread message queue. More...
void | osmo_it_q_destroy (struct osmo_it_q *q)
| Destroy a message queue. More...
void | osmo_it_q_flush (struct osmo_it_q *q)
| Flush all messages currently present in queue. More...

## Detailed Description

## Macro Definition Documentation

## osmo_it_q_dequeue

#define osmo_it_q_dequeue | ( |  | queue,
|  |  | item,
|  |  | member
| ) |  |

Value:
do { \
struct llist_head *l = _osmo_it_q_dequeue(queue); \
if (!l) \
*item = NULL; \
else \
*item = llist_entry(l, typeof(**item), member); \
} while (0)
llist_entry
#define llist_entry(ptr, type, member)
Get the struct containing this list entry.
Definition: linuxlist.h:218
_osmo_it_q_dequeue
struct llist_head * _osmo_it_q_dequeue(struct osmo_it_q *queue)
Thread-safe de-queue from an inter-thread message queue.
Definition: it_q.c:255
l
int gsm48_generate_mid_from_tmsi *(uint8_t *buf, uint32_t tmsi) OSMO_DEPRECATED_OUTSIDE("Instead u l))
llist_head
(double) linked list header structure
Definition: linuxlist.h:46

## osmo_it_q_enqueue

#define osmo_it_q_enqueue | ( |  | queue,
|  |  | item,
|  |  | member
| ) |  | _osmo_it_q_enqueue(queue, &(item)->member)

## Function Documentation

## _osmo_it_q_dequeue()

struct llist_head* _osmo_it_q_dequeue | ( | struct osmo_it_q * | queue | ) |

Thread-safe de-queue from an inter-thread message queue.

Parameters

  [in] | queue | Inter-thread queue from which to dequeue

Returns
  dequeued message buffer; NULL if none available

References current_length, l, list, llist_del(), llist_empty(), mutex, llist_head::next, and OSMO_ASSERT.

Referenced by osmo_it_q_fd_cb().

## _osmo_it_q_enqueue()

int _osmo_it_q_enqueue | ( | struct osmo_it_q * | queue,
|  | struct llist_head * | item
| ) |  |

Thread-safe en-queue to an inter-thread message queue.

Parameters

  [in] | queue | Inter-thread queue on which to enqueue
  [in] | item | Item to enqueue. Must have llist_head as first member!

Returns
  0 on success; negative on error

References current_length, event_ofd, eventfd_increment(), osmo_fd::fd, list, llist_add_tail(), max_length, mutex, and OSMO_ASSERT.

## osmo_it_q_alloc()

struct osmo_it_q* osmo_it_q_alloc | ( | void * | ctx,
|  | const char * | name,
|  | unsigned int | max_length,
|  | void(*)(struct osmo_it_q *q, struct llist_head *item) | read_cb,
|  | void * | data
| ) |  |

Allocate a new inter-thread message queue.

Parameters

  [in] | ctx | talloc context from which to allocate the queue
  [in] | name | human-readable string name of the queue; function creates a copy.
  [in] | read_cb | call-back function to be called for each de-queued message; may be NULL in case you don't want eventfd/osmo_select integration and will manually take care of noticing if and when to dequeue.

Returns
  a newly-allocated inter-thread message queue; NULL in case of error

References _osmo_it_q_by_name(), current_length, data, data, entry, event_ofd, osmo_fd::fd, INIT_LLIST_HEAD, it_queues_rwlock, list, llist_add_tail(), max_length, mutex, name, name, osmo_fd_close(), OSMO_FD_READ, osmo_fd_setup(), osmo_it_q_fd_cb(), and read_cb.

## osmo_it_q_by_name()

struct osmo_it_q* osmo_it_q_by_name | ( | const char * | name | ) |

resolve it-queue by its [globally unique] name

References _osmo_it_q_by_name(), it_queues_rwlock, and name.

## osmo_it_q_destroy()

void osmo_it_q_destroy | ( | struct osmo_it_q * | q | ) |

Destroy a message queue.

References entry, event_ofd, osmo_fd::fd, it_queues_rwlock, llist_del(), mutex, OSMO_ASSERT, osmo_fd_close(), and osmo_it_q_flush().

## osmo_it_q_flush()

void osmo_it_q_flush | ( | struct osmo_it_q * | q | ) |

Flush all messages currently present in queue.

References _osmo_it_q_flush(), mutex, and OSMO_ASSERT.

Referenced by osmo_it_q_destroy().