![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
external fota service implementation
ext_fota/msg_queue.cpp@0:bab3be8d31cf, 2015-06-19 (annotated)
- Committer:
- dudnwjs
- Date:
- Fri Jun 19 06:49:20 2015 +0000
- Revision:
- 0:bab3be8d31cf
add GAPM,GAPC header
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dudnwjs | 0:bab3be8d31cf | 1 | #include "msg_queue.h" |
dudnwjs | 0:bab3be8d31cf | 2 | #include "mbed.h" |
dudnwjs | 0:bab3be8d31cf | 3 | |
dudnwjs | 0:bab3be8d31cf | 4 | Msg_Queue::Msg_Queue(int MaxSize):MaxNum(MaxSize) |
dudnwjs | 0:bab3be8d31cf | 5 | { |
dudnwjs | 0:bab3be8d31cf | 6 | Front = NULL; |
dudnwjs | 0:bab3be8d31cf | 7 | Rear = NULL; |
dudnwjs | 0:bab3be8d31cf | 8 | ElemCnt = 0; |
dudnwjs | 0:bab3be8d31cf | 9 | } |
dudnwjs | 0:bab3be8d31cf | 10 | |
dudnwjs | 0:bab3be8d31cf | 11 | Msg_Queue::~Msg_Queue(void) |
dudnwjs | 0:bab3be8d31cf | 12 | { |
dudnwjs | 0:bab3be8d31cf | 13 | } |
dudnwjs | 0:bab3be8d31cf | 14 | |
dudnwjs | 0:bab3be8d31cf | 15 | void Msg_Queue::EnQueue(void *vData) |
dudnwjs | 0:bab3be8d31cf | 16 | { |
dudnwjs | 0:bab3be8d31cf | 17 | Element *tmp = new Element; |
dudnwjs | 0:bab3be8d31cf | 18 | tmp->Data = vData; |
dudnwjs | 0:bab3be8d31cf | 19 | tmp->Next = NULL; |
dudnwjs | 0:bab3be8d31cf | 20 | ElemCnt++; |
dudnwjs | 0:bab3be8d31cf | 21 | if( Front == NULL) |
dudnwjs | 0:bab3be8d31cf | 22 | { |
dudnwjs | 0:bab3be8d31cf | 23 | Front = tmp; |
dudnwjs | 0:bab3be8d31cf | 24 | Rear = tmp; |
dudnwjs | 0:bab3be8d31cf | 25 | }else |
dudnwjs | 0:bab3be8d31cf | 26 | { |
dudnwjs | 0:bab3be8d31cf | 27 | Rear->Next = tmp; |
dudnwjs | 0:bab3be8d31cf | 28 | Rear = tmp; |
dudnwjs | 0:bab3be8d31cf | 29 | } |
dudnwjs | 0:bab3be8d31cf | 30 | } |
dudnwjs | 0:bab3be8d31cf | 31 | |
dudnwjs | 0:bab3be8d31cf | 32 | void *Msg_Queue::DeQueue(void) |
dudnwjs | 0:bab3be8d31cf | 33 | { |
dudnwjs | 0:bab3be8d31cf | 34 | void *tmp; |
dudnwjs | 0:bab3be8d31cf | 35 | Element *tmpElem; |
dudnwjs | 0:bab3be8d31cf | 36 | |
dudnwjs | 0:bab3be8d31cf | 37 | if(Front == NULL) |
dudnwjs | 0:bab3be8d31cf | 38 | return NULL; |
dudnwjs | 0:bab3be8d31cf | 39 | |
dudnwjs | 0:bab3be8d31cf | 40 | ElemCnt--; |
dudnwjs | 0:bab3be8d31cf | 41 | tmpElem = Front; |
dudnwjs | 0:bab3be8d31cf | 42 | Front = tmpElem->Next; |
dudnwjs | 0:bab3be8d31cf | 43 | tmp = tmpElem->Data; |
dudnwjs | 0:bab3be8d31cf | 44 | free(tmpElem); |
dudnwjs | 0:bab3be8d31cf | 45 | |
dudnwjs | 0:bab3be8d31cf | 46 | return tmp; |
dudnwjs | 0:bab3be8d31cf | 47 | } |
dudnwjs | 0:bab3be8d31cf | 48 | |
dudnwjs | 0:bab3be8d31cf | 49 | int Msg_Queue::GetElementCount(void) |
dudnwjs | 0:bab3be8d31cf | 50 | { |
dudnwjs | 0:bab3be8d31cf | 51 | return ElemCnt; |
dudnwjs | 0:bab3be8d31cf | 52 | } |
dudnwjs | 0:bab3be8d31cf | 53 | |
dudnwjs | 0:bab3be8d31cf | 54 | bool Msg_Queue::IsEmpty(void) |
dudnwjs | 0:bab3be8d31cf | 55 | { |
dudnwjs | 0:bab3be8d31cf | 56 | if( Front == NULL) |
dudnwjs | 0:bab3be8d31cf | 57 | return false; |
dudnwjs | 0:bab3be8d31cf | 58 | else |
dudnwjs | 0:bab3be8d31cf | 59 | return true; |
dudnwjs | 0:bab3be8d31cf | 60 | } |
dudnwjs | 0:bab3be8d31cf | 61 | |
dudnwjs | 0:bab3be8d31cf | 62 |