author | Tero Marttila <terom@fixme.fi> |
Thu, 28 Aug 2008 01:34:14 +0300 | |
changeset 44 | 03a7e064f833 |
parent 37 | f0188b445c84 |
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_ENGINE_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_ENGINE_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 |
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
|
5 |
/* |
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 |
* Allocate a `struct cache`-compatible struct and return it via cache_ptr. |
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 |
*/ |
31 | 8 |
int (*fn_init) (struct cache_engine *, struct cache **); |
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
|
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 |
* Allocate a `struct cache_op`-compatible struct and return it via cache_ptr. |
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 |
* Begin the index 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
|
14 |
*/ |
31 | 15 |
int (*fn_op_start) (struct cache *, struct cache_op **, struct cache_key *); |
33 | 16 |
|
17 |
/* |
|
18 |
* Return some information about the available data. |
|
19 |
*/ |
|
36
b4023990811e
rename/clean up states slightly and add lots of documentation
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
20 |
int (*fn_op_available) (struct cache_op *, size_t *size, size_t *offset); |
b4023990811e
rename/clean up states slightly and add lots of documentation
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
21 |
|
b4023990811e
rename/clean up states slightly and add lots of documentation
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
22 |
/* |
b4023990811e
rename/clean up states slightly and add lots of documentation
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
23 |
* Prepare to read from this cache entry. |
b4023990811e
rename/clean up states slightly and add lots of documentation
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
24 |
*/ |
b4023990811e
rename/clean up states slightly and add lots of documentation
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
25 |
int (*fn_op_begin_read) (struct cache_op *); |
31 | 26 |
|
27 |
/* |
|
36
b4023990811e
rename/clean up states slightly and add lots of documentation
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
28 |
* Prepare to write to this cache entry. |
31 | 29 |
* |
30 |
* size_hint, if nonzero, provides a guess at the size of the cache entry that can be used to optimize stuff |
|
31 |
*/ |
|
32 |
int (*fn_op_begin_write) (struct cache_op *, size_t size_hint); |
|
33 | 33 |
|
34 |
/* |
|
35 |
* Read some data from the given fd into this cache entry. Size may contain a non-zero value to hint at how many |
|
36 |
* bytes should be read, or zero to just read a suitable amount. Should be updated to how many bytes were actually |
|
37 |
* written (may be zero if writes are currently paused). |
|
38 |
*/ |
|
36
b4023990811e
rename/clean up states slightly and add lots of documentation
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
39 |
int (*fn_op_push) (struct cache_op *, int fd, size_t *size); |
37 | 40 |
|
41 |
/* |
|
42 |
* Write some data into the given fd from this cache entry. Size either specifies how many bytes to read (and |
|
43 |
* should not be more than is available), or zero to read as much as possible. Offset is the offset from the |
|
44 |
* beginning of the cache entry, and should be updated to what the next unread byte would be. Size should be |
|
45 |
* updated to how many bytes was read. |
|
46 |
*/ |
|
47 |
int (*fn_op_pull) (struct cache_op *, int fd, size_t *offset, size_t *size); |
|
31 | 48 |
|
33 | 49 |
/* |
50 |
* No more calls to fn_op_push will take place. The cache entry now contains the complete data. |
|
51 |
*/ |
|
36
b4023990811e
rename/clean up states slightly and add lots of documentation
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
52 |
int (*fn_op_done) (struct cache_op *); |
33 | 53 |
|
54 |
/* |
|
55 |
* The op is not needed for any operations anymore. Free any resources and memory associated with this op, |
|
56 |
* including the op itself. |
|
57 |
*/ |
|
36
b4023990811e
rename/clean up states slightly and add lots of documentation
Tero Marttila <terom@fixme.fi>
parents:
33
diff
changeset
|
58 |
int (*fn_op_close) (struct cache_op *); |
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
|
59 |
}; |
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 |
|
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 |
#endif /* CACHE_ENGINE_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
|
62 |