ppool_queue.h 950 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef _PPOOL_QUEUE_H
  2. #define _PPOOL_QUEUE_H
  3. #include "ppool_errno.h"
  4. #include <stdlib.h>
  5. #include <string.h>
  6. #include <errno.h>
  7. typedef void (*ppool_work)(void *);
  8. typedef struct ppool_node
  9. {
  10. int priority; //优先级
  11. ppool_work task; //任务
  12. void *arg; //参数
  13. struct ppool_node *next;
  14. }pool_node;
  15. //任务列表头指针
  16. typedef struct
  17. {
  18. int len; //任务数量
  19. pool_node *head; //列表头指针
  20. }pool_w;
  21. pool_w *ppool_queue_init(void);
  22. //初始化一个任务列表
  23. pool_node *ppool_queue_new(ppool_work task,void *arg,int priority);
  24. /* 创建一个节点
  25. * task为新任务
  26. * arg为任务参数
  27. * priority为该任务优先级
  28. */
  29. void ppool_queue_add(pool_w *head,pool_node *node);
  30. // 添加一个任务
  31. pool_node *ppool_queue_get_task(pool_w *head);
  32. //获取一个任务
  33. void ppool_queue_cleanup(pool_w *head);
  34. //清理任务列表
  35. void ppool_queue_destroy(pool_w *head);
  36. //销毁任务列表
  37. #endif