4 * @brief Send-Queue based on linked_list_t
9 * Copyright (C) 2005 Jan Hutter, Martin Willi
10 * Hochschule fuer Technik Rapperswil
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
19 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 #include <network/packet.h>
32 * Although the send-queue is based on a linked_list_t
33 * all access functions are thread-save implemented
35 typedef struct send_queue_s send_queue_t
;
40 * @brief returns number of packets in queue
42 * @param send_queue_t calling object
43 * @param[out] count integer pointer to store the count in
44 * @returns number of items in queue
46 int (*get_count
) (send_queue_t
*send_queue
);
49 * @brief get the next packet from the queue
51 * If the queue is empty, this function blocks until a packet can be returned.
53 * After using, the returned packet has to get destroyed by the caller.
55 * @param send_queue_t calling object
56 * @param[out] packet pointer to a packet_t pointer where to packet is returned to
57 * @returns SUCCESS if succeeded, FAILED otherwise
59 status_t (*get
) (send_queue_t
*send_queue
, packet_t
**packet
);
62 * @brief adds a packet to the queue
64 * This function is non blocking and adds a packet_t to the list.
65 * The specific packet object has to get destroyed by the thread which
68 * @param send_queue_t calling object
69 * @param[in] packet packet_t to add to the queue (packet is not copied)
70 * @returns SUCCESS if succeeded, FAILED otherwise
72 status_t (*add
) (send_queue_t
*send_queue
, packet_t
*packet
);
75 * @brief destroys a send_queue object
77 * @warning The caller of this function has to make sure
78 * that no thread is going to add or get a packet from the send_queue
79 * after calling this function.
81 * @param send_queue_t calling object
82 * @returns SUCCESS if succeeded, FAILED otherwise
84 status_t (*destroy
) (send_queue_t
*send_queue
);
88 * @brief Creates an empty send_queue_t
90 * @return send_queue_t empty send_queue_t
92 send_queue_t
*send_queue_create();
94 #endif /*SEND_QUEUE_H_*/