libresman
annotate 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 |
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@22 | 13 |
nuclear@22 | 14 struct resource { |
nuclear@22 | 15 int id; |
nuclear@22 | 16 char *name; |
nuclear@22 | 17 void *data; |
nuclear@22 | 18 int result; /* last callback-reported success/fail code */ |
nuclear@22 | 19 |
nuclear@22 | 20 int done_pending; |
nuclear@22 | 21 int delete_pending; |
nuclear@22 | 22 pthread_mutex_t lock; |
nuclear@22 | 23 |
nuclear@22 | 24 int num_loads; /* number of loads up to now */ |
nuclear@22 | 25 |
nuclear@22 | 26 /* file change monitoring */ |
nuclear@22 | 27 #ifdef __WIN32__ |
nuclear@22 | 28 HANDLE nhandle; |
nuclear@22 | 29 #endif |
nuclear@22 | 30 #ifdef __linux__ |
nuclear@22 | 31 int nfd; |
nuclear@22 | 32 #endif |
nuclear@22 | 33 }; |
nuclear@22 | 34 |
nuclear@22 | 35 |
nuclear@22 | 36 struct resman { |
nuclear@22 | 37 struct resource **res; |
nuclear@22 | 38 struct thread_pool *tpool; |
nuclear@22 | 39 |
nuclear@22 | 40 pthread_mutex_t lock; /* global resman lock (for res array changes) */ |
nuclear@22 | 41 |
nuclear@22 | 42 resman_load_func load_func; |
nuclear@22 | 43 resman_done_func done_func; |
nuclear@22 | 44 resman_destroy_func destroy_func; |
nuclear@22 | 45 |
nuclear@22 | 46 void *load_func_cls; |
nuclear@22 | 47 void *done_func_cls; |
nuclear@22 | 48 void *destroy_func_cls; |
nuclear@22 | 49 |
nuclear@22 | 50 /* file change monitoring */ |
nuclear@22 | 51 struct rbtree *nresmap; |
nuclear@22 | 52 struct rbtree *modset; |
nuclear@22 | 53 #ifdef __linux__ |
nuclear@22 | 54 int inotify_fd; |
nuclear@22 | 55 #endif |
nuclear@22 | 56 }; |
nuclear@22 | 57 |
nuclear@22 | 58 |
nuclear@22 | 59 #endif /* RESMAN_IMPL_H_ */ |