libosmocore  1.5.1.205-e67e
Osmocom core library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
write_queue.h
Go to the documentation of this file.
1 
3 /*
4  * (C) 2010 by Holger Hans Peter Freyther
5  * (C) 2010 by On-Waves
6  *
7  * All Rights Reserved
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License along
20  * with this program; if not, write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22  *
23  */
24 #pragma once
25 
30 #include <osmocom/core/select.h>
31 #include <osmocom/core/msgb.h>
32 
34 struct osmo_wqueue {
36  struct osmo_fd bfd;
38  unsigned int max_length;
40  unsigned int current_length;
41 
44 
46  int (*read_cb)(struct osmo_fd *fd);
48  int (*write_cb)(struct osmo_fd *fd, struct msgb *msg);
50  int (*except_cb)(struct osmo_fd *fd);
51 };
52 
53 void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length);
54 void osmo_wqueue_clear(struct osmo_wqueue *queue);
55 int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data);
56 int osmo_wqueue_enqueue_quiet(struct osmo_wqueue *queue, struct msgb *data);
57 int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what);
58 
int(* except_cb)(struct osmo_fd *fd)
call-back in case qeueue has exceptions.
Definition: write_queue.h:50
Osmocom message buffer.
Definition: msgb.h:35
int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what)
Select loop function for write queue handling.
Definition: write_queue.c:43
void osmo_wqueue_clear(struct osmo_wqueue *queue)
Clear a osmo_wqueue.
Definition: write_queue.c:143
write queue instance
Definition: write_queue.h:34
void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length)
Initialize a osmo_wqueue structure.
Definition: write_queue.c:95
int(* read_cb)(struct osmo_fd *fd)
call-back in case qeueue is readable.
Definition: write_queue.h:46
struct llist_head msg_queue
actual linked list implementing the queue
Definition: write_queue.h:43
uint8_t data[0]
libmnl integration
(double) linked list header structure
Definition: linuxlist.h:46
unsigned int max_length
maximum length of write queue
Definition: write_queue.h:38
int osmo_wqueue_enqueue_quiet(struct osmo_wqueue *queue, struct msgb *data)
Enqueue a new Message buffers into a write queue (without logging full queue events) ...
Definition: write_queue.c:111
uint8_t msg[0]
struct osmo_fd bfd
osmocom file descriptor
Definition: write_queue.h:36
unsigned int current_length
current length of write queue
Definition: write_queue.h:40
Structure representing a file dsecriptor.
Definition: select.h:31
int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data)
Enqueue a new Message buffers into a write queue.
Definition: write_queue.c:127
int fd
actual operating-system level file decriptor
Definition: select.h:35
int(* write_cb)(struct osmo_fd *fd, struct msgb *msg)
call-back in case qeueue is writable.
Definition: write_queue.h:48