libresman
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/resman_impl.h Wed Feb 12 22:32:30 2014 +0200 1.3 @@ -0,0 +1,59 @@ 1.4 +#ifndef RESMAN_IMPL_H_ 1.5 +#define RESMAN_IMPL_H_ 1.6 + 1.7 +#include <pthread.h> 1.8 +#include "rbtree.h" 1.9 +#include "threadpool.h" 1.10 + 1.11 +#ifdef __linux__ 1.12 +#include <unistd.h> 1.13 +#include <fcntl.h> 1.14 +#include <sys/inotify.h> 1.15 +#endif 1.16 + 1.17 +struct resource { 1.18 + int id; 1.19 + char *name; 1.20 + void *data; 1.21 + int result; /* last callback-reported success/fail code */ 1.22 + 1.23 + int done_pending; 1.24 + int delete_pending; 1.25 + pthread_mutex_t lock; 1.26 + 1.27 + int num_loads; /* number of loads up to now */ 1.28 + 1.29 + /* file change monitoring */ 1.30 +#ifdef __WIN32__ 1.31 + HANDLE nhandle; 1.32 +#endif 1.33 +#ifdef __linux__ 1.34 + int nfd; 1.35 +#endif 1.36 +}; 1.37 + 1.38 + 1.39 +struct resman { 1.40 + struct resource **res; 1.41 + struct thread_pool *tpool; 1.42 + 1.43 + pthread_mutex_t lock; /* global resman lock (for res array changes) */ 1.44 + 1.45 + resman_load_func load_func; 1.46 + resman_done_func done_func; 1.47 + resman_destroy_func destroy_func; 1.48 + 1.49 + void *load_func_cls; 1.50 + void *done_func_cls; 1.51 + void *destroy_func_cls; 1.52 + 1.53 + /* file change monitoring */ 1.54 + struct rbtree *nresmap; 1.55 + struct rbtree *modset; 1.56 +#ifdef __linux__ 1.57 + int inotify_fd; 1.58 +#endif 1.59 +}; 1.60 + 1.61 + 1.62 +#endif /* RESMAN_IMPL_H_ */