Btrfs progs v4.17.1
[btrfs-progs-unstable/devel.git] / task-utils.h
blobbbb0f1fd9ff62878d17216e014c770b32f6dc6cf
1 /*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public
4 * License v2 as published by the Free Software Foundation.
6 * This program is distributed in the hope that it will be useful,
7 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9 * General Public License for more details.
11 * You should have received a copy of the GNU General Public
12 * License along with this program; if not, write to the
13 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
14 * Boston, MA 021110-1307, USA.
17 #ifndef __TASK_UTILS_H__
18 #define __TASK_UTILS_H__
20 #include "kerncompat.h"
21 #include <pthread.h>
23 struct periodic_info {
24 int timer_fd;
25 unsigned long long wakeups_missed;
28 struct task_info {
29 struct periodic_info periodic;
30 pthread_t id;
31 void *private_data;
32 void *(*threadfn)(void *);
33 int (*postfn)(void *);
36 /* task life cycle */
37 struct task_info *task_init(void *(*threadfn)(void *), int (*postfn)(void *),
38 void *thread_private);
39 int task_start(struct task_info *info, time_t *start_time, u64 *item_count);
40 void task_stop(struct task_info *info);
41 void task_deinit(struct task_info *info);
43 /* periodic life cycle */
44 int task_period_start(struct task_info *info, unsigned int period_ms);
45 void task_period_wait(struct task_info *info);
46 void task_period_stop(struct task_info *info);
48 #endif