HEAD: remove ridiculous dependency of wvmapi (actually wvtnef) on evolution
[wvapps.git] / funfs / cachefsrcache.h
blob7a935d2e52fd14843ffcf1f237d3a092778a7506
1 #ifndef __CACHEFSRCACHE_H
2 #define __CACHEFSRCACHE_H
4 #include <wvstring.h>
5 #include <wvhashtable.h>
6 #include <uniconf.h>
8 #include "wvdiskcache.h"
9 #include "cachefsicache.h"
11 typedef unsigned long int fino_t;
12 class WvStream;
13 class CacheFS;
14 class ReadCache;
16 class WaiterHelper
18 public:
19 WaiterHelper(size_t _index, WvStream *_waiter)
20 : index(_index), waiter(_waiter) {}
21 size_t index;
22 WvStream *waiter;
25 DeclareWvDict(WaiterHelper, size_t, index);
27 class RNode
29 public:
30 RNode(ReadCache *_rcache, int _fd, WvStringParm _parm, size_t _fsize);
31 ~RNode();
33 void maybe_schedule_readblock(CacheFS *cachefs, size_t index);
34 void update_page_status(size_t index, int status);
35 int wait_on_block(size_t index, WvStream *waiter);
36 int do_read(char *buf, size_t size, size_t offset);
37 void invalidate();
39 bool isok() { return m_data && m_header && fsize; }
41 int fd;
43 protected:
44 void do_map();
45 void do_unmap();
47 size_t fsize;
48 char *m_data, *m_header;
50 WvString path;
51 ReadCache *rcache;
52 WaiterHelperDict waiters;
55 DeclareWvDict(RNode, int, fd);
57 class ReadCache : public ICache
59 friend class RNode;
60 public:
61 ReadCache(UniConf _cfg);
62 virtual ~ReadCache() {};
64 void rcache_do_open(WvStringParm path, int fd);
65 void rcache_do_close(int fd);
66 void rcache_do_invalidate(int fd);
67 void rcache_do_invalidate(WvStringParm path);
69 int rcache_do_read(WvStream *waiter, int fd, char *buf, size_t size,
70 size_t off);
71 void update_page_status(int fd, size_t index, int status);
73 void diskcache_callback(WvStringParm path);
75 protected:
76 RNodeDict fdhash;
77 WvDiskCache diskcache;
80 #endif