libresman
view src/resman_impl.h @ 22:174ddb6bf92a
separated platform-specific filewatch code
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Wed, 12 Feb 2014 22:32:30 +0200 |
parents | |
children | f8e5a1491275 |
line source
1 #ifndef RESMAN_IMPL_H_
2 #define RESMAN_IMPL_H_
4 #include <pthread.h>
5 #include "rbtree.h"
6 #include "threadpool.h"
8 #ifdef __linux__
9 #include <unistd.h>
10 #include <fcntl.h>
11 #include <sys/inotify.h>
12 #endif
14 struct resource {
15 int id;
16 char *name;
17 void *data;
18 int result; /* last callback-reported success/fail code */
20 int done_pending;
21 int delete_pending;
22 pthread_mutex_t lock;
24 int num_loads; /* number of loads up to now */
26 /* file change monitoring */
27 #ifdef __WIN32__
28 HANDLE nhandle;
29 #endif
30 #ifdef __linux__
31 int nfd;
32 #endif
33 };
36 struct resman {
37 struct resource **res;
38 struct thread_pool *tpool;
40 pthread_mutex_t lock; /* global resman lock (for res array changes) */
42 resman_load_func load_func;
43 resman_done_func done_func;
44 resman_destroy_func destroy_func;
46 void *load_func_cls;
47 void *done_func_cls;
48 void *destroy_func_cls;
50 /* file change monitoring */
51 struct rbtree *nresmap;
52 struct rbtree *modset;
53 #ifdef __linux__
54 int inotify_fd;
55 #endif
56 };
59 #endif /* RESMAN_IMPL_H_ */