task_work.h 702 B

12345678910111213141516171819202122232425262728293031
  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. };
  11. static inline void
  12. init_task_work(struct task_work *twork, task_work_func_t func)
  13. {
  14. twork->func = func;
  15. }
  16. int task_work_add(struct task_struct *task, struct task_work *twork, bool);
  17. struct task_work *task_work_cancel(struct task_struct *, task_work_func_t);
  18. void task_work_run(void);
  19. static inline void exit_task_work(struct task_struct *task)
  20. {
  21. if (unlikely(!hlist_empty(&task->task_works)))
  22. task_work_run();
  23. }
  24. #endif /* _LINUX_TASK_WORK_H */