Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Queue Class Reference
queue modle More...
#include <queue.h>
Public Member Functions | |
| Queue (int iSize, int iCount) | |
| Create a Queue object. | |
| virtual | ~Queue (void) |
| destruction | |
| bool | Put (void *pvItem) |
| Add item to queue. | |
| bool | GetIrq (void *pvItem) |
| get an item from the queue in an IRQ handler | |
| bool | PutIrq (void *pvItem) |
| Add item to queue from an IRQ handler. | |
| bool | Get (void *pvItem) |
| get an item from the queue | |
| int | GetNumberOfItems (void) |
| get the number of items in the queue | |
| bool | Peek (void *pvItem) |
| peek at the entry at the top of the queue | |
| void | Flush (void) |
| flush the queue | |
Detailed Description
queue modle
Example:
#include "mbed.h" // include the queue library #include "queue.h" Serial myPc( USBTX, USBRX ); Queue myQueue( 1, 5 ); int main() { unsigned char nTemp; // display the number of items in the queue myPc.printf( "Items in queue: %d\r", myQueue.GetNumberOfItems( )); // add item to queue nTemp = 5; myQueue.Put( &nTemp ); nTemp = 6; myQueue.Put( &nTemp ); nTemp = 7; myQueue.Put( &nTemp ); // display the number of items in the queue myPc.printf( "Items in queue: %d\r", myQueue.GetNumberOfItems( )); // peek at item at the top of the queue myQueue.Peek( &nTemp ); myPc.printf( "Peek: %d\r", nTemp ); // get an item from queue myQueue.Get( &nTemp ); myPc.printf( "Item 0 = %d\r", nTemp ); myQueue.Get( &nTemp ); myPc.printf( "Item 1 = %d\r", nTemp ); // queue should be empty if ( !myQueue.Get( &nTemp )) { // queue is empty myPc.printf( "Queue empty!\r" ); } }
Definition at line 80 of file queue.h.
Constructor & Destructor Documentation
| Queue | ( | int | iSize, |
| int | iCount | ||
| ) |
Member Function Documentation
| bool Get | ( | void * | pvItem ) |
| bool GetIrq | ( | void * | pvItem ) |
| int GetNumberOfItems | ( | void | ) |
| bool Peek | ( | void * | pvItem ) |
| bool Put | ( | void * | pvItem ) |
Generated on Wed Nov 16 2022 04:14:06 by
1.7.2