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_error_code.h"
18#include "tuya_os_adapter.h"
19
20
25#define QUEUE_SAFE_FUNC
26
31typedef struct{
32 unsigned int queUnitSize; // queue unit size
33 unsigned int queTolNum; // queue total unit number
34 unsigned int queCurNum; // queue current unit number
35
36 unsigned char *queData; // queue buffer
37 unsigned char *queIn; // in queue position
38 unsigned char *queOut; // out queue position
39
40 #ifdef QUEUE_SAFE_FUNC
41 MUTEX_HANDLE mutex; // safity access prevent reentry
42 #endif
44
52P_QUEUE_CLASS CreateQueueObj(const unsigned int queTolNum, const unsigned int queUnitSize);
53
65unsigned char RegisterQueueObj(P_QUEUE_CLASS pQueObj, const unsigned char *pQueData, const unsigned int queTolNum, const unsigned int queUnitSize);
66
75unsigned char InQueue(P_QUEUE_CLASS pQueObj, const unsigned char *pQueUnit, const unsigned int queNum);
76
85unsigned char OutQueue(P_QUEUE_CLASS pQueObj,unsigned char *pQueUnit, const unsigned int queNum);
86
96unsigned char GetQueueMember(P_QUEUE_CLASS pQueObj, const unsigned int start, unsigned char *pQueUnit, const unsigned int queNum);
97
104unsigned char ClearQueue(P_QUEUE_CLASS pQueObj);
105
113unsigned char DelQueueMember(P_QUEUE_CLASS pQueObj,const unsigned int queNum);
114
121unsigned int GetCurFreeQueNum(P_QUEUE_CLASS pQueObj);
122
129unsigned int GetCurQueNum(P_QUEUE_CLASS pQueObj);
130
137
138
139#ifdef __cplusplus
140}
141#endif
142#endif
143
queue data structure define
Definition: uni_queue.h:31
Common process - Initialization
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