From cd0e0465d753255ba0f98a21e3c72f22d8a4b598 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Fri, 16 Aug 2013 19:43:50 +0200 Subject: SyncedRingbuffer Cleanup: private fields, clarify reset(boolean) --- .../jogamp/opengl/util/av/SyncedRingbuffer.java | 26 ++++++++++------------ 1 file changed, 12 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java b/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java index dff470eda..968a0cd1b 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java @@ -43,12 +43,12 @@ package jogamp.opengl.util.av; */ public class SyncedRingbuffer { - protected final Object sync = new Object(); - protected final T[] array; - protected final int capacity; - protected int readPos; - protected int writePos; - protected int size; + private final Object sync = new Object(); + private final T[] array; + private final int capacity; + private int readPos; + private int writePos; + private int size; public final String toString() { return "SyncedRingbuffer[filled "+size+" / "+capacity+", writePos "+writePos+", readPos "+readPos+"]"; @@ -74,9 +74,7 @@ public class SyncedRingbuffer { public final T[] getArray() { return array; } - public final int capacity() { - return capacity; - } + public final int capacity() { return capacity; } /** * Clears all ring buffer pointer to zero and set all ring buffer slots to null. @@ -91,16 +89,16 @@ public class SyncedRingbuffer { } /** - * Resets all ring buffer pointer to zero while leaving all ring buffer slots untouched. + * Sets the read and write position to zero and marks this ring buffer full or empty + * while leaving all ring buffer slots untouched. * @param full if true, this ring buffer is assumed to be full, i.e. {@link #isFull()} will return true. * Otherwise {@link #isEmpty()} will return true. */ public final void reset(boolean full) { synchronized ( sync ) { - clearImpl(false); - } - if(full) { - size = capacity; + readPos = 0; + writePos = 0; + size = full ? capacity : 0; } } -- cgit v1.2.3