kupl_queue_create_with_priority
创建一个kupl优先级队列。
接口定义
kupl_queue_h kupl_queue_create_with_priority(int priority);
环境变量
KUPL通过环境变量KUPL_ENABLE_PRIORITY来控制是否启用优先级。
环境变量KUPL_ENABLE_PRIORITY设置为1时,代表开启优先级功能;环境变量KUPL_ENABLE_PRIORITY设置为0时,代表优先级功能未开启。
参数
参数名 |
类型 |
描述 |
输入/输出 |
|---|---|---|---|
priority |
int |
队列优先级的值 |
输入 |
返回值
成功:返回创建的 queue
失败:返回nullptr
示例
1 2 3 4 5 6 7 8 9 10 11 12 13 | #include <stdio.h> #include "kupl.h" int main() { int least_priority; int greatest_priority; kupl_get_queue_priority_range(&least_priority, &greatest_priority); int priority = least_priority; kupl_queue_h queue = kupl_queue_create_with_priority(priority); kupl_queue_destroy(queue); return 0; } |
上述示例演示了创建、销毁一个优先级queue的流程。kupl_queue_create_with_priority函数创建了一个可复用的优先级queue。
父主题: 多队列多流编程函数