Queue Handler

Dependents:   BLE_ECG kragl kragl_v2 4180_final_project_v2 ... more

Embed: (wiki syntax)

« Back to documentation index

Queue Class Reference

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 
)

Create a Queue object.

Parameters:
iSizesize of the object in queue
iCountnumber of items in the queue

Definition at line 27 of file queue.cpp.

~Queue ( void   ) [virtual]

destruction

Definition at line 43 of file queue.cpp.


Member Function Documentation

void Flush ( void   )

flush the queue

Definition at line 179 of file queue.cpp.

bool Get ( void *  pvItem )

get an item from the queue

Parameters:
pvItempointer to the tiem to retrieve
Returns:
true if item fetched, false if queue is empty

Definition at line 77 of file queue.cpp.

bool GetIrq ( void *  pvItem )

get an item from the queue in an IRQ handler

Parameters:
pvItempointer to the tiem to retrieve
Returns:
true if item fetched, false if queue is empty

Definition at line 128 of file queue.cpp.

int GetNumberOfItems ( void   )

get the number of items in the queue

Returns:
the number of items in the queue

Definition at line 153 of file queue.cpp.

bool Peek ( void *  pvItem )

peek at the entry at the top of the queue

Returns:
the entry at the top of the queue

Definition at line 160 of file queue.cpp.

bool Put ( void *  pvItem )

Add item to queue.

Parameters:
pvItemitem to add
Returns:
true if item added, false if queue full

Definition at line 50 of file queue.cpp.

bool PutIrq ( void *  pvItem )

Add item to queue from an IRQ handler.

Parameters:
pvItemitem to add
Returns:
true if item added, false if queue full

Definition at line 103 of file queue.cpp.