TuyaOS
uni_queue.h
浏览该文件的文档.
1
10#ifndef _UNI_QUEUE_H
11#define _UNI_QUEUE_H
12
13#ifdef __cplusplus
14 extern "C" {
15#endif
16
17#include "tuya_cloud_types.h"
18#include "tal_mutex.h"
19
24typedef struct{
25 unsigned int queUnitSize; // queue unit size
26 unsigned int queTolNum; // queue total unit number
27 unsigned int queCurNum; // queue current unit number
28 unsigned char *queData; // queue buffer
29 unsigned char *queIn; // in queue position
30 unsigned char *queOut; // out queue position
31 MUTEX_HANDLE mutex; // safity access prevent reentry
33
41P_QUEUE_CLASS CreateQueueObj(const unsigned int queTolNum, const unsigned int queUnitSize);
42
54unsigned char RegisterQueueObj(P_QUEUE_CLASS pQueObj, const unsigned char *pQueData, const unsigned int queTolNum, const unsigned int queUnitSize);
55
64unsigned char InQueue(P_QUEUE_CLASS pQueObj, const unsigned char *pQueUnit, const unsigned int queNum);
65
74unsigned char OutQueue(P_QUEUE_CLASS pQueObj,unsigned char *pQueUnit, const unsigned int queNum);
75
85unsigned char GetQueueMember(P_QUEUE_CLASS pQueObj, const unsigned int start, unsigned char *pQueUnit, const unsigned int queNum);
86
93unsigned char ClearQueue(P_QUEUE_CLASS pQueObj);
94
102unsigned char DelQueueMember(P_QUEUE_CLASS pQueObj,const unsigned int queNum);
103
110unsigned int GetCurFreeQueNum(P_QUEUE_CLASS pQueObj);
111
118unsigned int GetCurQueNum(P_QUEUE_CLASS pQueObj);
119
126
127
128#ifdef __cplusplus
129}
130#endif
131#endif
132
queue data structure define
Definition: uni_queue.h:24
Common process - adapter the mutex api provide by OS
void ReleaseQueueObj(P_QUEUE_CLASS pQueObj)
release the queue
unsigned char ClearQueue(P_QUEUE_CLASS pQueObj)
clear all unit of the queue
unsigned int GetCurFreeQueNum(P_QUEUE_CLASS pQueObj)
get the free queue unit number
unsigned char InQueue(P_QUEUE_CLASS pQueObj, const unsigned char *pQueUnit, const unsigned int queNum)
unit inqueue
unsigned char RegisterQueueObj(P_QUEUE_CLASS pQueObj, const unsigned char *pQueData, const unsigned int queTolNum, const unsigned int queUnitSize)
register a queue, the queue handle and queue buffer malloc from other place
unsigned int GetCurQueNum(P_QUEUE_CLASS pQueObj)
get the queue unit number
unsigned char OutQueue(P_QUEUE_CLASS pQueObj, unsigned char *pQueUnit, const unsigned int queNum)
unit outqueue
unsigned char DelQueueMember(P_QUEUE_CLASS pQueObj, const unsigned int queNum)
delete the unit from the queue out position
unsigned char GetQueueMember(P_QUEUE_CLASS pQueObj, const unsigned int start, unsigned char *pQueUnit, const unsigned int queNum)
get the unit from start postion, not outqueue
P_QUEUE_CLASS CreateQueueObj(const unsigned int queTolNum, const unsigned int queUnitSize)
create and initialize a queue