libresman
view src/resman_impl.h @ 26:6b9974a8bdae
started BSD/mac support for file watching
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 31 Mar 2014 19:51:00 +0300 |
parents | ce04fa12afdd |
children |
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 #if defined(__FreeBSD__) || defined(__APPLE__)
14 #include <sys/event.h>
15 #endif
16 #ifdef WIN32
17 #include <windows.h>
18 #endif
20 struct resource {
21 int id;
22 char *name;
23 void *data;
24 int result; /* last callback-reported success/fail code */
26 int done_pending;
27 int delete_pending;
28 pthread_mutex_t lock;
30 int num_loads; /* number of loads up to now */
32 /* file change monitoring */
33 #ifdef WIN32
34 char *watch_path;
35 #endif
36 #ifdef __linux__
37 int nfd;
38 #endif
39 #if defined(__FreeBSD__) || defined(__APPLE__)
40 struct kevent kev;
41 #endif
42 };
45 struct resman {
46 struct resource **res;
47 struct thread_pool *tpool;
49 pthread_mutex_t lock; /* global resman lock (for res array changes) */
51 resman_load_func load_func;
52 resman_done_func done_func;
53 resman_destroy_func destroy_func;
55 void *load_func_cls;
56 void *done_func_cls;
57 void *destroy_func_cls;
59 /* file change monitoring */
60 struct rbtree *nresmap;
61 #ifdef __linux__
62 int inotify_fd;
63 struct rbtree *modset;
64 #endif
65 #if defined(__FreeBSD__) || defined(__APPLE__)
66 int kq;
67 #endif
68 #ifdef WIN32
69 struct rbtree *watchdirs, *wdirbyev;
70 HANDLE *watch_handles; /* dynamic array of all the watched directory handles */
71 #endif
72 };
75 #endif /* RESMAN_IMPL_H_ */