📄 queue.h
字号:
/******************************************************************************
Copyright (c) 2006 by RockOS.
All rights reserved.
This software is supported by the Rock Software Workroom only.
Any bugs please contact the author with e-mail or QQ:
E-mail : baobaoba520@yahoo.com.cn
QQ : 59681888
*******************************************************************************
File name : queue.h
Description : header file for queue algrithm in RockOS. Including FIFO based
: queue and priority based queue.
:
Auther : sunxinqiu
History :
2006-3-15 first release.
******************************************************************************/
#ifndef __QUEUE_H__
#define __QUEUE_H__
#ifdef __cplusplus
extern "C" {
#endif
enum
{
OS_QUEUE_FREE = 0,
OS_QUEUE_FIFO = 1,
OS_QUEUE_LIFO = 2,
OS_QUEUE_PRIO = 3,
OS_QUEUE_SET = 4
};
enum
{
QELEMENT_FREE = 0,
QELEMENT_BUSY = 1
};
typedef struct
{
U32 next; /* next element in queue. */
HANDLE handle; /* the data handle. */
}Q_BASIC_ELEMENT;
typedef struct
{
U32 next; /* next element in queue. */
U16 priority; /* the priority. */
HANDLE handle; /* the data handle. */
}Q_PRIO_ELEMENT;
typedef struct
{
U32 total;
U32 current;
HANDLE head;
HANDLE tail;
}QFREE;
typedef struct
{
U16 state; /* the queue's state or type. */
HTASK owner; /* the owner task. */
char name[MAX_NAME_LEN+1]; /* the name. */
U32 total; /* queue's size, max elements in queue. */
U32 current; /* current elements in queue */
U32 head; /* the first element of queue. */
U32 tail; /* the last element of queue. */
}QCB;
STATUS queue_init(void);
HQUEUE q_create(U16 type, U32 qsize, HTASK owner, const char * name);
STATUS q_destroy(HQUEUE qid);
STATUS q_add(HQUEUE qid, HANDLE handle, U16 priority);
STATUS q_enum (HQUEUE qid, HANDLE * phandle);
STATUS q_head (HQUEUE qid, HANDLE * phandle);
STATUS q_del (HQUEUE qid, HANDLE handle);
U32 q_count (HQUEUE qid);
void q_showAll(void);
void q_showSingle(HQUEUE qid);
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -