miosix::Queue< T, len > Class Template Reference
[Syncronization]
#include <sync.h>
List of all members.
Detailed Description
template<typename T, unsigned int len>
class miosix::Queue< T, len >
A queue, used to transfer data between TWO threads, or between ONE thread and an IRQ.
If you need to tranfer data between more than two threads, you need to use mutexes to ensure that only one thread at a time calls get, and only one thread at a time calls put.
This queue is meant to be a static or global class. Dynamically creating a queue with new or on the stack must be done with care, to avoid deleting a queue with a waiting thread, and to avoid situations where a thread tries to access a deleted queue.
- Template Parameters:
-
| T | the type of elements in the queue |
| len | the length of the Queue |
Constructor & Destructor Documentation
template<typename T , unsigned int len>
Constructor, create a new empty queue.
Member Function Documentation
template<typename T , unsigned int len>
Get an element from the queue. If the queue is empty, then sleep until an element becomes available.
- Parameters:
-
| elem | an element from the queue |
template<typename T , unsigned int len>
bool miosix::Queue< T, len >::IRQget |
( |
T & |
elem, |
|
|
bool & |
hppw | |
|
) |
| | [inline] |
Get an element from the queue, only if the queue is not empty.
Can ONLY be used inside an IRQ, or when interrupts are disabled.
- Parameters:
-
| elem | an element from the queue. The element is valid only if the return value is true |
| hppw | is not modified if no thread is woken or if the woken thread has a lower or equal priority than the currently running thread, else is set to true |
- Returns:
- true if the queue was not empty
template<typename T , unsigned int len>
Get an element from the queue, only if the queue is not empty.
Can ONLY be used inside an IRQ, or when interrupts are disabled.
- Parameters:
-
| elem | an element from the queue. The element is valid only if the return value is true |
- Returns:
- true if the queue was not empty
template<typename T , unsigned int len>
bool miosix::Queue< T, len >::IRQput |
( |
T |
elem, |
|
|
bool & |
hppw | |
|
) |
| | [inline] |
Put an element to the queue, only if th queue is not full.
Can ONLY be used inside an IRQ, or when interrupts are disabled.
- Parameters:
-
| elem | element to add. The element has been added only if the return value is true |
| hppw | is not modified if no thread is woken or if the woken thread has a lower or equal priority than the currently running thread, else is set to true |
- Returns:
- true if the queue was not full.
template<typename T , unsigned int len>
Put an element to the queue, only if th queue is not full.
Can ONLY be used inside an IRQ, or when interrupts are disabled.
- Parameters:
-
| elem | element to add. The element has been added only if the return value is true |
- Returns:
- true if the queue was not full.
template<typename T , unsigned int len>
Same as reset(), but to be used only inside IRQs or when interrupts are disabled.
template<typename T , unsigned int len>
- Returns:
- true if the queue is empty
template<typename T , unsigned int len>
- Returns:
- true if the queue is full
template<typename T , unsigned int len>
Put an element to the queue. If the queue is full, then sleep until a place becomes available.
- Parameters:
-
| elem | element to add to the queue |
template<typename T , unsigned int len>
Clear all items in the queue.
Cannot be used inside an IRQ
template<typename T , unsigned int len>
If a queue is empty, waits until the queue is not empty.
template<typename T , unsigned int len>
If a queue is full, waits until the queue is not full
The documentation for this class was generated from the following file:
- /Users/fede/Documents/Projects/ARM/miosix/miosix_np_2/miosix/kernel/sync.h