]> git.proxmox.com Git - pve-cluster.git/blob - data/src/loop.h
8c0a02666d9b7181bfae914269b6c5bc13f7b624
[pve-cluster.git] / data / src / loop.h
1 /*
2 Copyright (C) 2010 Proxmox Server Solutions GmbH
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU Affero General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU Affero General Public License for more details.
13
14 You should have received a copy of the GNU Affero General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 Author: Dietmar Maurer <dietmar@proxmox.com>
18
19 */
20
21 #ifndef _PVE_LOOP_H_
22 #define _PVE_LOOP_H_
23
24 #define FUSE_USE_VERSION 26
25
26 #include <glib.h>
27 #include <fuse.h>
28 #include <qb/qbdefs.h>
29 #include <qb/qbutil.h>
30 #include <qb/qbloop.h>
31
32 typedef struct cfs_loop cfs_loop_t;
33
34 typedef struct cfs_service cfs_service_t;
35
36 typedef int (*cfs_service_initialize_fn_t)(
37 cfs_service_t *service,
38 gpointer context);
39
40 typedef gboolean (*cfs_service_finalize_fn_t)(
41 cfs_service_t *service,
42 gpointer context);
43
44 typedef gboolean (*cfs_service_dispatch_fn_t)(
45 cfs_service_t *service,
46 gpointer context);
47
48 typedef void (*cfs_service_timer_fn_t)(
49 cfs_service_t *service,
50 gpointer context);
51
52 typedef struct {
53 cfs_service_initialize_fn_t cfs_service_initialize_fn;
54 cfs_service_finalize_fn_t cfs_service_finalize_fn;
55 cfs_service_dispatch_fn_t cfs_service_dispatch_fn;
56 cfs_service_timer_fn_t cfs_service_timer_fn;
57 } cfs_service_callbacks_t;
58
59 cfs_service_t *cfs_service_new(
60 cfs_service_callbacks_t *callbacks,
61 const char *log_domain,
62 gpointer context);
63
64 gpointer cfs_service_get_context(
65 cfs_service_t *service);
66
67 gboolean cfs_service_set_timer(
68 cfs_service_t *service,
69 time_t period);
70
71 void cfs_service_set_restartable(
72 cfs_service_t *service,
73 gboolean restartable);
74
75 cfs_loop_t *cfs_loop_new(struct fuse *fuse);
76
77 void cfs_loop_destroy(
78 cfs_loop_t *loop);
79
80 gboolean cfs_loop_add_service(
81 cfs_loop_t *loop,
82 cfs_service_t *service,
83 enum qb_loop_priority priority);
84
85 gboolean cfs_loop_start_worker(
86 cfs_loop_t *loop);
87
88 void cfs_loop_stop_worker(
89 cfs_loop_t *loop);
90
91
92 #endif /* _PVE_LOOP_H_ */