]>
Commit | Line | Data |
---|---|---|
ddd639f6 JH |
1 | /** |
2 | * @file send_queue.h | |
c3dc6f1a | 3 | * |
d048df5c | 4 | * @brief Interface of send_queue_t. |
c3dc6f1a | 5 | * |
ddd639f6 JH |
6 | */ |
7 | ||
8 | /* | |
9 | * Copyright (C) 2005 Jan Hutter, Martin Willi | |
10 | * Hochschule fuer Technik Rapperswil | |
11 | * | |
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>. | |
16 | * | |
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 | |
20 | * for more details. | |
21 | */ | |
22 | ||
23 | #ifndef SEND_QUEUE_H_ | |
24 | #define SEND_QUEUE_H_ | |
25 | ||
8080fccb | 26 | #include <types.h> |
716abc9f | 27 | #include <network/packet.h> |
ddd639f6 | 28 | |
95c61cb9 JH |
29 | |
30 | typedef struct send_queue_t send_queue_t; | |
31 | ||
ddd639f6 | 32 | /** |
a6cbf648 MW |
33 | * @brief The send queue stores packet for the sender_t instance. |
34 | * | |
35 | * The sender_t will send them consequently over the wire. | |
c3dc6f1a | 36 | * Although the send-queue is based on a linked_list_t |
df3c59d0 MW |
37 | * all access functions are thread-save implemented. |
38 | * | |
a6cbf648 MW |
39 | * @b Constructors: |
40 | * - send_queue_create() | |
41 | * | |
df3c59d0 | 42 | * @ingroup queues |
ddd639f6 | 43 | */ |
95c61cb9 | 44 | struct send_queue_t { |
c3dc6f1a | 45 | |
ddd639f6 JH |
46 | /** |
47 | * @brief returns number of packets in queue | |
c3dc6f1a | 48 | * |
d048df5c MW |
49 | * @param send_queue_t calling object |
50 | * @param[out] count integer pointer to store the count in | |
51 | * @returns number of items in queue | |
ddd639f6 | 52 | */ |
1061c878 | 53 | int (*get_count) (send_queue_t *send_queue); |
ddd639f6 JH |
54 | |
55 | /** | |
d048df5c | 56 | * @brief get the next packet from the queue. |
c3dc6f1a | 57 | * |
ddd639f6 | 58 | * If the queue is empty, this function blocks until a packet can be returned. |
c3dc6f1a | 59 | * |
ddd639f6 | 60 | * After using, the returned packet has to get destroyed by the caller. |
c3dc6f1a | 61 | * |
d048df5c | 62 | * @param send_queue_t calling object |
df3c59d0 | 63 | * @return next packet from the queue |
ddd639f6 | 64 | */ |
d048df5c | 65 | packet_t *(*get) (send_queue_t *send_queue); |
c3dc6f1a | 66 | |
ddd639f6 | 67 | /** |
d048df5c | 68 | * @brief adds a packet to the queue. |
c3dc6f1a | 69 | * |
ddd639f6 | 70 | * This function is non blocking and adds a packet_t to the list. |
c3dc6f1a | 71 | * The specific packet object has to get destroyed by the thread which |
ddd639f6 | 72 | * removes the packet. |
c3dc6f1a | 73 | * |
d048df5c MW |
74 | * @param send_queue_t calling object |
75 | * @param packet packet_t to add to the queue (packet is not copied) | |
ddd639f6 | 76 | */ |
d048df5c | 77 | void (*add) (send_queue_t *send_queue, packet_t *packet); |
ddd639f6 JH |
78 | |
79 | /** | |
d048df5c | 80 | * @brief destroys a send_queue object. |
c3dc6f1a | 81 | * |
ddd639f6 JH |
82 | * @warning The caller of this function has to make sure |
83 | * that no thread is going to add or get a packet from the send_queue | |
84 | * after calling this function. | |
c3dc6f1a | 85 | * |
df3c59d0 | 86 | * @param send_queue_t calling object |
ddd639f6 | 87 | */ |
d048df5c | 88 | void (*destroy) (send_queue_t *send_queue); |
ddd639f6 JH |
89 | }; |
90 | ||
91 | /** | |
d048df5c | 92 | * @brief Creates an empty send_queue_t. |
c3dc6f1a | 93 | * |
a6cbf648 | 94 | * @return send_queue_t object |
df3c59d0 MW |
95 | * |
96 | * @ingroup queues | |
ddd639f6 | 97 | */ |
f768bdc3 | 98 | send_queue_t *send_queue_create(void); |
ddd639f6 JH |
99 | |
100 | #endif /*SEND_QUEUE_H_*/ |