31 lines
1.5 KiB
C
31 lines
1.5 KiB
C
/*
|
|
* ringbuffer.h
|
|
*
|
|
* Created on: Apr 1, 2011
|
|
* Author: sears
|
|
*/
|
|
|
|
#ifndef RINGBUFFER_H_
|
|
#define RINGBUFFER_H_
|
|
#include <stasis/common.h>
|
|
BEGIN_C_DECLS
|
|
|
|
typedef struct stasis_ringbuffer_t stasis_ringbuffer_t;
|
|
|
|
stasis_ringbuffer_t * stasis_ringbuffer_init(intptr_t size, int64_t initial_offset);
|
|
int64_t stasis_ringbuffer_nb_reserve_space(stasis_ringbuffer_t * ring, int64_t sz);
|
|
int64_t stasis_ringbuffer_reserve_space(stasis_ringbuffer_t * ring, int64_t sz, int64_t * handle);
|
|
void stasis_ringbuffer_read_done(stasis_ringbuffer_t * ring, int64_t * handle);
|
|
void stasis_ringbuffer_advance_write_tail(stasis_ringbuffer_t * ring, int64_t off);
|
|
const void * stasis_ringbuffer_nb_get_rd_buf(stasis_ringbuffer_t * ring, int64_t off, int64_t sz);
|
|
// sz is a pointer to the desired size, or RING_NEXT for "as many bytes as possible"
|
|
int64_t stasis_ringbuffer_consume_bytes(stasis_ringbuffer_t * ring, int64_t* sz, int64_t * handle);
|
|
void stasis_ringbuffer_write_done(stasis_ringbuffer_t * ring, int64_t * handle);
|
|
// sz is a pointer to the desired size, or RING_NEXT for "as many bytes as possible"
|
|
const void * stasis_ringbuffer_get_rd_buf(stasis_ringbuffer_t * ring, int64_t off, int64_t* sz);
|
|
void * stasis_ringbuffer_get_wr_buf(stasis_ringbuffer_t * ring, int64_t off, int64_t sz);
|
|
void stasis_ringbuffer_advance_read_tail(stasis_ringbuffer_t * ring, int64_t off);
|
|
typedef enum { RING_TORN = -1, RING_VOLATILE = -2, RING_FULL = -3, RING_TRUNCATED = -4, RING_NEXT = -5, RING_MINERR = -6 } stasis_ringbuffer_error_t;
|
|
|
|
END_C_DECLS
|
|
#endif /* RINGBUFFER_H_ */
|