Chris BAYLEY / Mbed 2 deprecated UARTSnoop

Dependencies:   MODSERIAL Terminal mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TinyQueue.cpp Source File

TinyQueue.cpp

00001 #include "TinyQueue.h"
00002 
00003 
00004 
00005 
00006 /**
00007  * \brief Push an Accessibility Event onto our queue for sending to the iphone
00008  * \param q pointer to our tinyQ_t
00009  * \param c the Event to send to the iphone
00010  * \return null if Q full,  1 on success
00011  * \sa Qpop(), Qjump()
00012  * \ingroup tinyQ
00013  */
00014 int Qpush( tinyQ_t* q, void* p )
00015 {
00016    if (q->fill >= Q_SIZE)
00017       return 0;
00018 
00019    q->fill++;
00020    q->data[q->head++] = p;
00021 
00022    return 1;
00023 }
00024 
00025 /**
00026  * \brief Push an Accessibility Event onto front of our queue for sending to the iphone
00027  * \param q pointer to our tinyQ_t
00028  * \param c the Event to send to the iphone
00029  * \return null if Q full, 1 on success
00030  * \sa Qpush(), Qpop()
00031  * \ingroup tinyQ
00032  */
00033 int Qjump( tinyQ_t* q, void* p)
00034 {
00035    if (q->fill >= Q_SIZE)
00036       return 0;
00037 
00038    q->fill++;
00039    q->data[--q->tail] = p;
00040 
00041    return 1;
00042 }
00043 
00044 /**
00045  * \brief Pop an Accessibility Event off our queue for sending to the iphone
00046  * \param q pointer to our tinyQ_t
00047  * \param c pointer to receive the Event
00048  * \return null if Q empty, 1 on success
00049  * \sa Qpop(), Qjump()
00050  * \ingroup tinyQ
00051  */
00052 int Qpop( tinyQ_t* q, void **p)
00053 {
00054    if (! q->fill )
00055       return 0;
00056 
00057    q->fill--;
00058    *p = q->data[q->tail++];
00059 
00060    return 1;
00061 }
00062 
00063 /* @} */