changeset 2183:b73ea297d197

- New version of ringbuffer code
author Ralf Ertzinger <ralf@skytale.net>
date Thu, 22 Nov 2007 15:51:52 +0100
parents cc5e9ec110a4
children f2590691d4b7
files src/neon/rb.c src/neon/rb.h
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/neon/rb.c	Thu Nov 22 02:54:06 2007 +0300
+++ b/src/neon/rb.c	Thu Nov 22 15:51:52 2007 +0100
@@ -343,12 +343,23 @@
     _ENTER;
 
     _RB_LOCK(rb->lock);
-    u = rb->used;
+    u = used_rb_locked(rb);
     _RB_UNLOCK(rb->lock);
 
     _LEAVE u;
 }
 
+/*
+ * Return the amount of used space currently in the rb.
+ * Assume the rb lock is already being held.
+ */
+unsigned int used_rb_locked(struct ringbuf* rb) {
+
+    _ENTER;
+
+    _LEAVE rb->used;
+}
+
 
 /*
  * destroy a ringbuffer
--- a/src/neon/rb.h	Thu Nov 22 02:54:06 2007 +0300
+++ b/src/neon/rb.h	Thu Nov 22 15:51:52 2007 +0100
@@ -61,6 +61,7 @@
 unsigned int free_rb(struct ringbuf* rb);
 unsigned int free_rb_locked(struct ringbuf* rb);
 unsigned int used_rb(struct ringbuf* rb);
+unsigned int used_rb_locked(struct ringbuf* rb);
 void destroy_rb(struct ringbuf* rb);
 
 #endif