write_queue.h
Go to the documentation of this file.
/*
* (C) 2010 by Holger Hans Peter Freyther
* (C) 2010 by On-Waves
*
* All Rights Reserved
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#pragma once
#include <osmocom/core/select.h>
#include <osmocom/core/msgb.h>
struct osmo_wqueue {
struct osmo_fd bfd;
unsigned int max_length;
unsigned int current_length;
struct llist_head msg_queue;
int (*read_cb)(struct osmo_fd *fd);
int (*write_cb)(struct osmo_fd *fd, struct msgb *msg);
int (*except_cb)(struct osmo_fd *fd);
};
void osmo_wqueue_init(struct osmo_wqueue *queue, int max_length);
void osmo_wqueue_clear(struct osmo_wqueue *queue);
int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data);
int osmo_wqueue_bfd_cb(struct osmo_fd *fd, unsigned int what);
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
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
int osmo_wqueue_enqueue(struct osmo_wqueue *queue, struct msgb *data)
Enqueue a new Message buffers into a write queue.
Definition: write_queue.c:108
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:92
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:23
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:27
osmo_fd::data
void * data
data pointer passed through to call-back function
Definition: select.h:35
osmo_wqueue_clear
void osmo_wqueue_clear(struct osmo_wqueue *queue)
Clear a osmo_wqueue.
Definition: write_queue.c:128