btrfs-progs: tests: remove trivial use of local variables
[platform/upstream/btrfs-progs.git] / task-utils.h
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.
5  *
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.
10  *
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.
15  */
16
17 #ifndef __TASK_UTILS_H__
18 #define __TASK_UTILS_H__
19
20 #include <pthread.h>
21
22 struct periodic_info {
23         int timer_fd;
24         unsigned long long wakeups_missed;
25 };
26
27 struct task_info {
28         struct periodic_info periodic;
29         pthread_t id;
30         void *private_data;
31         void *(*threadfn)(void *);
32         int (*postfn)(void *);
33 };
34
35 /* task life cycle */
36 struct task_info *task_init(void *(*threadfn)(void *), int (*postfn)(void *),
37                             void *thread_private);
38 int task_start(struct task_info *info);
39 void task_stop(struct task_info *info);
40 void task_deinit(struct task_info *info);
41
42 /* periodic life cycle */
43 int task_period_start(struct task_info *info, unsigned int period_ms);
44 void task_period_wait(struct task_info *info);
45 void task_period_stop(struct task_info *info);
46
47 #endif