This repository has been archived by the owner on Mar 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathvmemcache.h
74 lines (59 loc) · 1.85 KB
/
vmemcache.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
// SPDX-License-Identifier: BSD-3-Clause
/* Copyright 2018-2019, Intel Corporation */
/*
* vmemcache.h -- internal definitions for vmemcache
*/
#ifndef VMEMCACHE_H
#define VMEMCACHE_H 1
#include <stdint.h>
#include <stddef.h>
#include "libvmemcache.h"
#include "vmemcache_heap.h"
#ifdef __cplusplus
extern "C" {
#endif
#define VMEMCACHE_PREFIX "libvmemcache"
#define VMEMCACHE_LEVEL_VAR "VMEMCACHE_LEVEL"
#define VMEMCACHE_FILE_VAR "VMEMCACHE_FILE"
struct index;
struct repl_p;
struct vmemcache {
void *addr; /* mapping address */
size_t size; /* mapping size */
size_t extent_size; /* heap granularity */
struct heap *heap; /* heap address */
struct index *index; /* indexing structure */
enum vmemcache_repl_p repl_p; /* replacement policy */
struct repl_p *repl; /* replacement policy abstraction */
vmemcache_on_evict *on_evict; /* callback on evict */
void *arg_evict; /* argument for callback on evict */
vmemcache_on_miss *on_miss; /* callback on miss */
void *arg_miss; /* argument for callback on miss */
unsigned ready:1; /* is the cache ready for use? */
unsigned index_only:1; /* bench: disable repl+alloc */
unsigned no_alloc:1; /* bench: disable allocations */
unsigned no_memcpy:1; /* bench: don't copy actual data */
};
struct cache_entry {
struct value {
uint32_t refcount;
int evicting;
struct repl_p_entry *p_entry;
size_t vsize;
ptr_ext_t *extents;
} value;
struct key {
size_t ksize;
char key[];
} key;
};
/* type of callback deleting a cache entry */
typedef void (*delete_entry_t)(struct cache_entry *entry);
/* callback deleting a cache entry (of the above type 'delete_entry_t') */
void vmemcache_delete_entry_cb(struct cache_entry *entry);
void vmemcache_entry_acquire(struct cache_entry *entry);
void vmemcache_entry_release(VMEMcache *cache, struct cache_entry *entry);
#ifdef __cplusplus
}
#endif
#endif