author | terom@cl-543.hel-01.fi.sixxs.net |
Thu, 07 Aug 2008 20:28:06 +0300 | |
changeset 30 | 33e464fd6773 |
child 31 | 12d5361e7472 |
permissions | -rw-r--r-- |
30
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
1 |
#ifndef CACHE_H |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
2 |
#define CACHE_H |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
3 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
4 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
5 |
* The interface to the internal caching mechanism. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
6 |
* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
7 |
* This presents a pretty generic API, which allows the actual implementation to change, or to compare multiple |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
8 |
* different implementations. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
9 |
* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
10 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
11 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
12 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
13 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
14 |
* The handle used to access the global cache. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
15 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
16 |
struct cache; |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
17 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
18 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
19 |
* A cache request/operation. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
20 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
21 |
struct cache_req; |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
22 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
23 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
24 |
* The actual implementation of the cache. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
25 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
26 |
struct cache_engine; |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
27 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
28 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
29 |
* What we use as keys in the cache. Key is a pointer to an arbitrary char buffer, length is the size of the key |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
30 |
* in bytes. If this is given as zero, it will be calcuated using strlen(). Zero-length keys are invalid. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
31 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
32 |
struct cache_key_t { |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
33 |
const char *buf; |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
34 |
size_t length; |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
35 |
}; |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
36 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
37 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
38 |
* The various states that a cache request can be in |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
39 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
40 |
enum cache_req_state { |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
41 |
CACHE_STATE_INVALID, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
42 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
43 |
CACHE_STATE_LOOKUP, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
44 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
45 |
CACHE_STATE_OPEN, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
46 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
47 |
CACHE_STATE_WRITE, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
48 |
CACHE_STATE_WRITE_PAUSE, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
49 |
CACHE_STATE_READ, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
50 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
51 |
CACHE_STATE_DONE, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
52 |
CACHE_STATE_ERROR, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
53 |
}; |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
54 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
55 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
56 |
* Transitions between states |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
57 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
58 |
enum cache_req_event { |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
59 |
// LOOKUP -> OPEN |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
60 |
CACHE_EVENT_HIT, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
61 |
CACHE_EVENT_MISS, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
62 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
63 |
// OPEN -> WRITE |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
64 |
CACHE_EVENT_BEGIN_WRITE, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
65 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
66 |
// OPEN -> READ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
67 |
CACHE_EVENT_BEGIN_READ, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
68 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
69 |
// WRITE -> PAUSE_WRITE |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
70 |
CACHE_EVENT_PAUSE_WRITE, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
71 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
72 |
// PAUSE_WRITE -> WRITE |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
73 |
CACHE_EVENT_RESUME_WRITE, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
74 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
75 |
// READ -> READ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
76 |
CACHE_EVENT_DATA_AVAILABLE, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
77 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
78 |
// READ -> DONE |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
79 |
CACHE_EVENT_DONE, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
80 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
81 |
// * -> ERROR |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
82 |
CACHE_EVENT_ERROR, |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
83 |
}; |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
84 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
85 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
86 |
* The callback used for cache_reqs |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
87 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
88 |
typedef (int) (*cache_callback) (struct cache_req *, enum cache_req_event, void *arg); |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
89 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
90 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
91 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
92 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
93 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
94 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
95 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
96 |
* Open up a cache using the given engine (which can be configured with engine-specific params). |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
97 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
98 |
struct cache *cache_open (struct cache_engine *engine); |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
99 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
100 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
101 |
* Create a new request. The given callback function will be called at the various stages in the request, and can then |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
102 |
* drive the request forward. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
103 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
104 |
struct cache_req *cache_request (struct cache *cache, struct cache_key *key, cache_callback cb_func, void *cb_data); |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
105 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
106 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
107 |
* Get the request's state. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
108 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
109 |
enum cache_req_state cache_request_state (struct cache_req *req); |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
110 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
111 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
112 |
* Get information about the amount of data in this cache entry. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
113 |
* size - the total size of the cache entry. -1 if unknown |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
114 |
* offset - how many bytes of data the cache entry contains |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
115 |
* available - how many unread bytes are available |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
116 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
117 |
void cache_req_available (struct cache_req *req, ssize_t *size, ssize_t *offset, ssize_t *available); |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
118 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
119 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
120 |
* Add some data into this cache entry, reading from the given fd. This is only valid for cache_req's in |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
121 |
* CACHE_REQ_WRITE mode. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
122 |
* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
123 |
* If you know the amount of data that should be pushed, you can supply it in size. If size is given as 0, all |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
124 |
* available data will be consumed. Size will be updated to the number of bytes pushed into the cache. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
125 |
* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
126 |
* (size == 0) is valid if req is in the WRITE_PAUSE state (either before or after the call). |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
127 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
128 |
int cache_req_push (struct cache_req *req, int fd, size_t *size); |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
129 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
130 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
131 |
* Get some data from this cache entry, writing it into the given fd. This is valid for all cache_req's in |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
132 |
* CACHE_REQ_READ and CACHE_REQ_WRITE mode. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
133 |
* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
134 |
* If the value of size is given (nonzero), then the given amount of data will be written to the fd from the cache. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
135 |
* If the cache contains less data than given, this is an error. If the value of size is zero, as much data as possible |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
136 |
* will be written to the fd. Size will be updated to the number of bytes pulled from the cache. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
137 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
138 |
int cache_req_pull (struct cache_req *req, int fd, size_t *size); |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
139 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
140 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
141 |
* Abort the given cache request (external failure). This is only needed for CACHE_REQ_WRITE requests, and is invalid |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
142 |
* for other requests. Any dependant cache requests will fail. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
143 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
144 |
void cache_req_abort (struct cache_req *req); |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
145 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
146 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
147 |
* Indicate that the given cache write request is complete. This is only valid for CACHE_REQ_WRITE requests, and is |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
148 |
* invalid for other requests. Any dependant cache requests will complete. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
149 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
150 |
int cache_req_done (struct cache_req *req); |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
151 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
152 |
/* |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
153 |
* Release the given cache request. Only valid after calling req_abort/req_done, or getting EVENT_DONE/EVENT_ERROR. |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
154 |
*/ |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
155 |
void cache_req_release (struct cache_req *req); |
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
156 |
|
33e464fd6773
my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
terom@cl-543.hel-01.fi.sixxs.net
parents:
diff
changeset
|
157 |
#endif /* CACHE_H */ |