libresman

view src/resman_impl.h @ 23:f8e5a1491275

win32 file change notification attempt1 (failed)
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 13 Feb 2014 13:17:07 +0200
parents 174ddb6bf92a
children ce04fa12afdd
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
13 #ifdef WIN32
14 #include <windows.h>
15 #endif
17 struct resource {
18 int id;
19 char *name;
20 void *data;
21 int result; /* last callback-reported success/fail code */
23 int done_pending;
24 int delete_pending;
25 pthread_mutex_t lock;
27 int num_loads; /* number of loads up to now */
29 /* file change monitoring */
30 #ifdef WIN32
31 HANDLE nhandle;
32 char *watch_path;
33 #endif
34 #ifdef __linux__
35 int nfd;
36 #endif
37 };
40 struct resman {
41 struct resource **res;
42 struct thread_pool *tpool;
44 pthread_mutex_t lock; /* global resman lock (for res array changes) */
46 resman_load_func load_func;
47 resman_done_func done_func;
48 resman_destroy_func destroy_func;
50 void *load_func_cls;
51 void *done_func_cls;
52 void *destroy_func_cls;
54 /* file change monitoring */
55 struct rbtree *nresmap;
56 #ifdef __linux__
57 int inotify_fd;
58 struct rbtree *modset;
59 #endif
60 #ifdef WIN32
61 struct rbtree *watchdirs;
62 HANDLE *watch_handles; /* dynamic array of all the watch handles */
63 #endif
64 };
67 #endif /* RESMAN_IMPL_H_ */