forked from Netflix/dynomite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdyn_ring_queue.h
94 lines (62 loc) · 1.79 KB
/
dyn_ring_queue.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*
* Dynomite - A thin, distributed replication layer for multi non-distributed storages.
* Copyright (C) 2014 Netflix, Inc.
*/
#include "dyn_gossip.h"
#ifndef _DYN_RING_QUEUE_
#define _DYN_RING_QUEUE_
#define C2G_InQ_SIZE 256
#define C2G_OutQ_SIZE 256
#define C2S_InQ_SIZE 256
#define C2S_OutQ_SIZE 256
struct node;
typedef rstatus_t (*callback_t)(void *msg);
typedef void (*data_func_t)(void *);
volatile struct
{
long m_getIdx;
long m_putIdx;
void* m_entry[C2G_InQ_SIZE];
} C2G_InQ;
volatile struct
{
long m_getIdx;
long m_putIdx;
void* m_entry[C2G_OutQ_SIZE];
} C2G_OutQ;
struct ring_msg {
callback_t cb;
uint8_t *data; /* place holder for a msg */
uint32_t capacity; /* max capacity */
uint32_t len; /* # of useful bytes in data (len =< capacity) */
struct array nodes;
struct server_pool *sp;
};
volatile struct
{
long m_getIdx;
long m_putIdx;
void* m_entry[C2S_InQ_SIZE];
} C2S_InQ;
volatile struct
{
long m_getIdx;
long m_putIdx;
void* m_entry[C2S_OutQ_SIZE];
} C2S_OutQ;
struct stat_msg {
void* cb;
void* post_cb;
void* data;
stats_cmd_t cmd;
};
struct ring_msg *create_ring_msg(void);
struct ring_msg *create_ring_msg_with_data(int capacity);
struct ring_msg *create_ring_msg_with_size(uint32_t size, bool init_node);
rstatus_t ring_msg_init(struct ring_msg *msg, uint32_t size, bool init_node);
rstatus_t ring_msg_deinit(struct ring_msg *msg);
struct node * create_node(void);
rstatus_t node_init(struct node *node);
rstatus_t node_deinit(struct node *node);
rstatus_t node_copy(const struct node *src, struct node *dst);
#endif