libosmocore  1.5.1
Osmocom core library
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 
43  struct llist_head msg_queue;
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 
osmo_wqueue::current_length
unsigned int current_length
current length of write queue
Definition: write_queue.h:40
osmo_wqueue::max_length
unsigned int max_length
maximum length of write queue
Definition: write_queue.h:38
osmo_wqueue::write_cb
int(* write_cb)(struct osmo_fd *fd, struct msgb *msg)
call-back in case qeueue is writable.
Definition: write_queue.h:48
msg
uint8_t msg[0]
data
uint8_t data[0]
msgb
Osmocom message buffer.
Definition: msgb.h:35
osmo_wqueue::read_cb
int(* read_cb)(struct osmo_fd *fd)
call-back in case qeueue is readable.
Definition: write_queue.h:46
osmo_wqueue_enqueue_quiet
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
osmo_wqueue_enqueue
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
osmo_wqueue
write queue instance
Definition: write_queue.h:34
osmo_wqueue::except_cb
int(* except_cb)(struct osmo_fd *fd)
call-back in case qeueue has exceptions.
Definition: write_queue.h:50
llist_head
(double) linked list header structure
Definition: linuxlist.h:46
osmo_wqueue_init
void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length)
Initialize a osmo_wqueue structure.
Definition: write_queue.c:95
msgb.h
osmo_wqueue::bfd
struct osmo_fd bfd
osmocom file descriptor
Definition: write_queue.h:36
select.h
osmo_fd
Structure representing a file dsecriptor.
Definition: select.h:31
osmo_wqueue_bfd_cb
int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what)
Select loop function for write queue handling.
Definition: write_queue.c:43
osmo_wqueue::msg_queue
struct llist_head msg_queue
actual linked list implementing the queue
Definition: write_queue.h:43
osmo_fd::fd
int fd
actual operating-system level file decriptor
Definition: select.h:35
osmo_wqueue_clear
void osmo_wqueue_clear(struct osmo_wqueue *queue)
Clear a osmo_wqueue.
Definition: write_queue.c:143