task_work.h 748 B

123456789101112131415161718192021222324252627282930313233
  1. #ifndef _LINUX_TASK_WORK_H
  2. #define _LINUX_TASK_WORK_H
  3. #include <linux/list.h>
  4. #include <linux/sched.h>
  5. struct task_work;
  6. typedef void (*task_work_func_t)(struct task_work *);
  7. struct task_work {
  8. struct hlist_node hlist;
  9. task_work_func_t func;
  10. void *data;
  11. };
  12. static inline void
  13. init_task_work(struct task_work *twork, task_work_func_t func, void *data)
  14. {
  15. twork->func = func;
  16. twork->data = data;
  17. }
  18. int task_work_add(struct task_struct *task, struct task_work *twork, bool);
  19. struct task_work *task_work_cancel(struct task_struct *, task_work_func_t);
  20. void task_work_run(void);
  21. static inline void exit_task_work(struct task_struct *task)
  22. {
  23. if (unlikely(!hlist_empty(&task->task_works)))
  24. task_work_run();
  25. }
  26. #endif /* _LINUX_TASK_WORK_H */