-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadditive_list.h
38 lines (26 loc) · 1.17 KB
/
additive_list.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
#ifndef CONCURRENCY_ADDITIVE_LIST_H
#define CONCURRENCY_ADDITIVE_LIST_H
#include <stdint.h>
#include <malloc.h>
#include <string.h>
// potential performance improvement with blockMultiplier being a power of 2 (for modulo)
// TODO: add cacheline alignment to reduce the number of cachelines needed to load/store an element
typedef struct AdditiveList_t {
uint16_t elementSize;
uint16_t blockMultiplier;
uint16_t maxBlock;
uint64_t offset;
uint16_t currentBlockNumber;
uint32_t currentBlockStartIndex;
uint32_t listLength;
uint16_t arrayOffset;
char **blockArrayPointer;
} AdditiveList;
int additive_list_init(AdditiveList *additiveList, uint16_t elementSize, uint16_t blockMultiplier, uint16_t maxBlock,
uint64_t offset);
int additive_list_add(AdditiveList *additiveList, void *data);
void *additive_list_get(AdditiveList *additiveList, uint64_t offsetIndex);
int additive_list_get_copy(AdditiveList *additiveList, uint64_t offsetIndex, void *copy);
void additive_list_remove_before(AdditiveList *additiveList, uint64_t offsetIndex);
void additive_list_free(AdditiveList *additiveList);
#endif //CONCURRENCY_ADDITIVE_LIST_H