4 template<class kind
> class HeapRing
{
6 // smoothie-specific friend classes
13 HeapRing(unsigned int length
);
23 void push_front(kind
&) __attribute__ ((warning("Not thread-safe if pop_back() is used in ISR context!"))); // instead, prepare(head_ref()); produce_head();
24 kind
& pop_back(void) __attribute__ ((warning("Not thread-safe if head_ref() is used to prepare new items, or push_front() is used in ISR context!"))); // instead, consume(tail_ref()); consume_tail();
32 void produce_head(void);
33 void consume_tail(void);
38 bool is_empty(void) const;
39 bool is_full(void) const;
44 * returns true on success, or false if queue is not empty or not enough memory available
46 bool resize(unsigned int);
50 * kind* - new buffer pointer
51 * int length - number of items in buffer (NOT size in bytes!)
53 * cause HeapRing to use a specific memory location instead of allocating its own
55 * returns true on success, or false if queue is not empty
57 bool provide(kind
*, unsigned int length
);
61 * these functions are protected as they should only be used internally
62 * or in extremely specific circumstances
64 kind
& item(unsigned int);
65 kind
* item_ref(unsigned int);
67 unsigned int next(unsigned int) const;
68 unsigned int prev(unsigned int) const;
75 volatile unsigned int head_i
;
76 volatile unsigned int tail_i
;
77 volatile unsigned int isr_tail_i
;
83 #endif /* _HEAPRING_H */