btrfs-progs: fix nanosecs in task_period_start
[btrfs-progs-unstable/devel.git] / task-utils.h
blob91d5a6463c8e85fa9872752fc71b4813a443e3c2
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 <pthread.h>
22 struct periodic_info {
23 int timer_fd;
24 unsigned long long wakeups_missed;
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 *);
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);
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);
47 #endif