|
PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
|
Go to the documentation of this file.
29 #include <propeller.h>
32 #ifdef __PROPELLER_COG__
33 #define PropWare PropWare_cog
55 m_lockNumber(lockNumber),
71 Queue (T *array,
const size_t length,
const int lockNumber)
73 m_arrayLength(length),
101 return 0 == this->
size();
110 return this->m_arrayLength == this->
size();
131 while (
lockset(this->m_lockNumber));
132 unsigned int head = this->m_head;
133 unsigned int tail = this->m_tail;
134 size_t size = this->m_size;
142 if (head == this->m_arrayLength)
146 this->m_array[head] = value;
149 if (
size == this->m_arrayLength) {
152 if (tail == this->m_arrayLength)
183 while (
lockset(this->m_lockNumber));
184 unsigned int head = this->m_head;
185 unsigned int tail = this->m_tail;
186 size_t size = this->m_size;
190 retVal = &this->m_array[tail];
197 if (tail == this->m_arrayLength)
220 return this->m_array[this->m_tail];
235 const bool valid = &value == NULL;
241 const size_t m_arrayLength;
242 const int m_lockNumber;
244 volatile size_t m_size;
245 volatile unsigned int m_head;
246 volatile unsigned int m_tail;
251 #ifdef __PROPELLER_COG__
A basic first-in, first-out queue implementation. The queue will overwrite itself when the maximum si...
Queue(T *array, const size_t length, const int lockNumber)
Construct a queue using the given dynamically allocated array (i.e., with new or malloc)
bool is_empty() const
Determine if any elements exist.
bool is_full() const
Determine if inserting another element would overwrite data.
size_t size() const
Obtain the number of elements in the queue.
T peek() const
Return the oldest value in the buffer without removing it from the buffer.
Queue(T(&array)[N], const int lockNumber=locknew())
Construct a queue using the given statically-allocated array.
#define lockset(lockid)
Set a lock.
virtual T dequeue()
Return and remove the oldest value in the buffer.
#define lockret(lockid)
Return lock to pool.
#define lockclr(lockid)
Clear lock.
virtual Queue & enqueue(const T &value)
Insert an element to the buffer.
#define locknew()
Get a new lock from the pool of Propeller hardware locks.
Queue & insert(const T &value)
Generic definitions and functions for the Parallax Propeller.
void clear()
Remove all data from the queue.
bool check(const T &value) const
Determine if a value is valid.