Contiki-NG
|
ringbufindex library. More...
Go to the source code of this file.
Functions | |
void | ringbufindex_init (struct ringbufindex *r, uint8_t size) |
Initialize a ring buffer. | |
int | ringbufindex_put (struct ringbufindex *r) |
Put one element to the ring buffer. | |
int | ringbufindex_peek_put (const struct ringbufindex *r) |
Check if there is space to put an element. | |
int | ringbufindex_get (struct ringbufindex *r) |
Remove the first element and return its index. | |
int | ringbufindex_peek_get (const struct ringbufindex *r) |
Return the index of the first element which will be removed if calling ringbufindex_get. | |
ringbufindex library.
Implements basic support for ring buffers of any type, as opposed to the os/lib/ringbuf module which is only for byte arrays. Simply returns index in the ringbuf rather than actual elements. The ringbuf size must be power of two. Like the original ringbuf, this module implements atomic put and get.
Definition in file ringbufindex.c.
int ringbufindex_get | ( | struct ringbufindex * | r | ) |
Remove the first element and return its index.
r | Pinter to ringbufindex |
>= | 0 The index of the first element |
-1 | No element in the ring buffer |
Definition at line 90 of file ringbufindex.c.
Referenced by tsch_queue_remove_packet_from_queue().
void ringbufindex_init | ( | struct ringbufindex * | r, |
uint8_t | size ) |
Initialize a ring buffer.
The size must be a power of two
r | Pointer to ringbufindex |
size | Size of ring buffer |
Definition at line 50 of file ringbufindex.c.
Referenced by tsch_queue_add_nbr().
int ringbufindex_peek_get | ( | const struct ringbufindex * | r | ) |
Return the index of the first element which will be removed if calling ringbufindex_get.
r | Pinter to ringbufindex |
>= | 0 The index of the first element |
-1 | No element in the ring buffer |
Definition at line 115 of file ringbufindex.c.
Referenced by tsch_queue_get_packet_for_nbr().
int ringbufindex_peek_put | ( | const struct ringbufindex * | r | ) |
Check if there is space to put an element.
r | Pinter to ringbufindex |
>= | 0 The index where the next element is to be added. |
-1 | Failure; the ring buffer is full |
Definition at line 78 of file ringbufindex.c.
Referenced by tsch_queue_add_packet(), tsch_rx_slot(), and tsch_tx_slot().
int ringbufindex_put | ( | struct ringbufindex * | r | ) |
Put one element to the ring buffer.
r | Pointer to ringbufindex |
0 | Failure; the ring buffer is full |
1 | Success; an element is added |
Definition at line 58 of file ringbufindex.c.
Referenced by tsch_queue_add_packet(), tsch_rx_slot(), and tsch_tx_slot().