Ai
1 Star 1 Fork 7

觉皇/QueueBuffer

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
main.c 803 Bytes
一键复制 编辑 原始数据 按行查看 历史
觉皇 提交于 2022-12-25 13:34 +08:00 . 优化提交
/*
* mian.c
*
* Created on: 2020年10月12日
* Author: hello
*/
#include <stdio.h>
#include <string.h>
#include "queue.h"
/* 队列大小 */
#define QUEUE_SIZE 100
/* 队列数据空间。请使用宏QALIGN4,目的是为了根据队列大小计算实际需要的队列存储空间大小并对齐4字节 */
uint8_t QueueBuffer[QALIGN4(QUEUE_SIZE)];
/* 队列句柄 */
Queue queue;
QueuePtr queueHandle = &queue;
// 多线程请实现加锁
static void qlock(void)
{
printf("lock\n");
}
// 多线程请实现解锁
static void qunlock(void)
{
printf("unlock\n");
}
int main()
{
char buf[20];
memset(buf, 0X00, sizeof(buf));
// 静态初始化
Queue_Init(&queue, QUEUE_SIZE, QueueBuffer, qlock, qunlock);
// 写
Queue_Write(queueHandle, "HelloWorld", 10);
// 读
Queue_Read(queueHandle, buf, 10);
// 打印
printf("read:%s\n", buf);
return 0;
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/jhembed/QueueBuffer.git
git@gitee.com:jhembed/QueueBuffer.git
jhembed
QueueBuffer
QueueBuffer
master

搜索帮助