diff options
Diffstat (limited to 'lf_ring_buffer.h')
-rw-r--r-- | lf_ring_buffer.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lf_ring_buffer.h b/lf_ring_buffer.h index 790cba9..51d29e5 100644 --- a/lf_ring_buffer.h +++ b/lf_ring_buffer.h @@ -32,18 +32,22 @@ extern "C" { # endif /* __cplusplus */ +#include <sys/types.h> #include "lf_ring_buffer_data.h" -#define BACKOFF_DELAY_INIT 1000 -#define BACKOFF_DELAY_INC 3000 -#define BACKOFF_DELAY_MAX 90000 +#define BACKOFF_DELAY_INIT 100 +#define BACKOFF_DELAY_INC 100 +#define BACKOFF_DELAY_MAX 1000 -#define LFRB_NO_BLOCK 1 /* if buffer is full, leave instead of try again and again */ +#define LFRB_NO_BLOCK 1 /* if buffer is full, leave instead of try again and again */ #define IS_NOT_BLOCKING( flags ) ( (flags)&LFRB_NO_BLOCK ) +#define LFRB_NO_BACKOFF_INC 2 /* do not use BACKOFF_DELAY_X */ +#define BACKOFF_INC_NOT( flags ) ( (flags)&LFRB_NO_BACKOFF_INC ) + typedef struct ring_buffer { LFRB_BUFFER_TYPE *buffer; /* buffer data */ - int n_buf; /* number of buffers */ + size_t n_buf; /* number of buffers */ int read_from; /* index where to read data from */ int write_to; /* index where to write data to */ int write_delay; /* backoff nanosleep to reduce fast looping when writing */ @@ -51,7 +55,7 @@ typedef struct ring_buffer { } lf_ring_buffer_t; /* return an initialized lf_ring_buffer_t struct */ -lf_ring_buffer_t* lf_ring_buffer_create( int n_buf ); +lf_ring_buffer_t* lf_ring_buffer_create( size_t n_buf ); /* destroy an lf_ring_buffer_t struct */ void lf_ring_buffer_destroy( lf_ring_buffer_t *r ); |