-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharc.h
60 lines (48 loc) · 1.25 KB
/
arc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// Created by chenrun on 2024/10/29.
//
#ifndef ADAPTIVE_REPLACEMENT_CACHE_ARC_H
#define ADAPTIVE_REPLACEMENT_CACHE_ARC_H
#include <stddef.h>
/* List elements */
struct arc_list_s {
struct arc_list_s *prev;
struct arc_list_s *next;
};
/* ARC definitions */
typedef enum {
None,
MRU,
MFU,
GMRU,
GMFU,
} eARCType;
struct arc_object_s {
struct arc_list_s list;
eARCType type;
};
struct arc_status_s {
struct arc_object_s objects;
unsigned int size; /* Track linked list sizes to adjust policies */
};
struct arc_ops_s {
int (*cmp) (const void *key, struct arc_object_s *obj);
int (*fetch) (struct arc_object_s *obj);
struct arc_object_s *(*create) (const void *key);
void (*evacuate) (struct arc_object_s *obj);
void (*destroy) (struct arc_object_s *obj);
};
struct arc_s {
struct arc_ops_s *ops;
struct arc_status_s mru;
struct arc_status_s mfu;
struct arc_status_s gmfu;
struct arc_status_s gmru;
unsigned int p;
unsigned int ce; /* Number of cache entrys */
};
void arc_dump(struct arc_s *arc);
void arc_destroy(struct arc_s *cache);
struct arc_s *arc_create(struct arc_ops_s *ops, unsigned int cache_size);
struct arc_object_s *arc_lookup(struct arc_s *cache, const void *key);
#endif //ADAPTIVE_REPLACEMENT_CACHE_ARC_H