libresman
annotate 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 |
rev | line source |
---|---|
nuclear@22 | 1 #ifndef RESMAN_IMPL_H_ |
nuclear@22 | 2 #define RESMAN_IMPL_H_ |
nuclear@22 | 3 |
nuclear@22 | 4 #include <pthread.h> |
nuclear@22 | 5 #include "rbtree.h" |
nuclear@22 | 6 #include "threadpool.h" |
nuclear@22 | 7 |
nuclear@22 | 8 #ifdef __linux__ |
nuclear@22 | 9 #include <unistd.h> |
nuclear@22 | 10 #include <fcntl.h> |
nuclear@22 | 11 #include <sys/inotify.h> |
nuclear@22 | 12 #endif |
nuclear@26 | 13 #if defined(__FreeBSD__) || defined(__APPLE__) |
nuclear@26 | 14 #include <sys/event.h> |
nuclear@26 | 15 #endif |
nuclear@23 | 16 #ifdef WIN32 |
nuclear@23 | 17 #include <windows.h> |
nuclear@23 | 18 #endif |
nuclear@22 | 19 |
nuclear@22 | 20 struct resource { |
nuclear@22 | 21 int id; |
nuclear@22 | 22 char *name; |
nuclear@22 | 23 void *data; |
nuclear@22 | 24 int result; /* last callback-reported success/fail code */ |
nuclear@22 | 25 |
nuclear@22 | 26 int done_pending; |
nuclear@22 | 27 int delete_pending; |
nuclear@22 | 28 pthread_mutex_t lock; |
nuclear@22 | 29 |
nuclear@22 | 30 int num_loads; /* number of loads up to now */ |
nuclear@22 | 31 |
nuclear@22 | 32 /* file change monitoring */ |
nuclear@23 | 33 #ifdef WIN32 |
nuclear@23 | 34 char *watch_path; |
nuclear@22 | 35 #endif |
nuclear@22 | 36 #ifdef __linux__ |
nuclear@22 | 37 int nfd; |
nuclear@22 | 38 #endif |
nuclear@26 | 39 #if defined(__FreeBSD__) || defined(__APPLE__) |
nuclear@26 | 40 struct kevent kev; |
nuclear@26 | 41 #endif |
nuclear@22 | 42 }; |
nuclear@22 | 43 |
nuclear@22 | 44 |
nuclear@22 | 45 struct resman { |
nuclear@22 | 46 struct resource **res; |
nuclear@22 | 47 struct thread_pool *tpool; |
nuclear@22 | 48 |
nuclear@22 | 49 pthread_mutex_t lock; /* global resman lock (for res array changes) */ |
nuclear@22 | 50 |
nuclear@22 | 51 resman_load_func load_func; |
nuclear@22 | 52 resman_done_func done_func; |
nuclear@22 | 53 resman_destroy_func destroy_func; |
nuclear@22 | 54 |
nuclear@22 | 55 void *load_func_cls; |
nuclear@22 | 56 void *done_func_cls; |
nuclear@22 | 57 void *destroy_func_cls; |
nuclear@22 | 58 |
nuclear@22 | 59 /* file change monitoring */ |
nuclear@22 | 60 struct rbtree *nresmap; |
nuclear@22 | 61 #ifdef __linux__ |
nuclear@22 | 62 int inotify_fd; |
nuclear@23 | 63 struct rbtree *modset; |
nuclear@23 | 64 #endif |
nuclear@26 | 65 #if defined(__FreeBSD__) || defined(__APPLE__) |
nuclear@26 | 66 int kq; |
nuclear@26 | 67 #endif |
nuclear@23 | 68 #ifdef WIN32 |
nuclear@24 | 69 struct rbtree *watchdirs, *wdirbyev; |
nuclear@24 | 70 HANDLE *watch_handles; /* dynamic array of all the watched directory handles */ |
nuclear@22 | 71 #endif |
nuclear@22 | 72 }; |
nuclear@22 | 73 |
nuclear@22 | 74 |
nuclear@22 | 75 #endif /* RESMAN_IMPL_H_ */ |