-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathringbuffer.h
More file actions
35 lines (28 loc) · 889 Bytes
/
Copy pathringbuffer.h
File metadata and controls
35 lines (28 loc) · 889 Bytes
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
#ifndef __RINGBUFFER_H__
#define __RINGBUFFER_H__
/**
* Copyright (c) 2014, Zhiyong Liu <Neesenk at gmail dot com>
* All rights reserved.
*/
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
struct ringbuffer;
struct reader_result
{
size_t beg;
size_t end;
size_t cur;
struct ringbuffer *ring;
};
struct ringbuffer *ringbuffer_create(size_t size, size_t max);
void ringbuffer_destroy(struct ringbuffer *ring);
void *ringbuffer_result_next(struct reader_result *res, size_t *size);
int ringbuffer_reader_parpare(struct ringbuffer *ring, struct reader_result *res);
void ringbuffer_reader_commit(struct ringbuffer *ring, struct reader_result *res);
void *ringbuffer_writer_parpare(struct ringbuffer *ring, size_t size);
void ringbuffer_writer_commit(struct ringbuffer *ring, void *ptr);
#ifdef __cplusplus
}
#endif // __cplusplus
#endif // __RINGBUFFER_H__