-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrb.h
57 lines (36 loc) · 1.09 KB
/
rb.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
#ifndef _RB_H
#define _RB_H 1
#include <proton/types.h>
#include <time.h>
#include <pthread.h>
typedef struct {
pn_rwbytes_t *ring_buffer;
int count;
int buf_size;
bool wake_producer;
volatile int head;
volatile int tail;
pthread_mutex_t rb_mutex;
pthread_cond_t rb_ready;
pthread_cond_t rb_free;
// stats
//
// Buffer full
volatile long overruns;
// Number of messages procesed
volatile long processed;
volatile long queue_block;
struct timespec total_active, total_wait;
struct timespec total_t1, total_t2;
} rb_rwbytes_t;
extern rb_rwbytes_t *rb_alloc(int count, int buf_size, bool wake_producer);
extern pn_rwbytes_t *rb_get_head(rb_rwbytes_t *rb);
extern pn_rwbytes_t *rb_get_tail(rb_rwbytes_t *rb);
extern pn_rwbytes_t *rb_put(rb_rwbytes_t *rb);
extern pn_rwbytes_t *rb_get(rb_rwbytes_t *rb);
extern void rb_free(rb_rwbytes_t *rb);
extern int rb_free_size(rb_rwbytes_t *rb);
extern int rb_inuse_size(rb_rwbytes_t *rb);
extern int rb_size(rb_rwbytes_t *rb);
extern long rb_get_queue_block(rb_rwbytes_t *rb);
#endif