summaryrefslogtreecommitdiffstats
path: root/lf_ring_buffer.h
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2010-01-07 18:00:21 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2010-01-07 18:00:21 +0100
commitde7ceedae12efca39ec9128e9accdbc3e6f416f9 (patch)
tree150b0754af9bbf3c7ffb963351a2a490b6e752de /lf_ring_buffer.h
parent82a5bc70e5f85d7d40e04e6a7dc567b086025421 (diff)
downloadlock_free-de7ceedae12efca39ec9128e9accdbc3e6f416f9.zip
lock_free-de7ceedae12efca39ec9128e9accdbc3e6f416f9.tar.gz
parallel tests
Diffstat (limited to 'lf_ring_buffer.h')
-rw-r--r--lf_ring_buffer.h16
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 );