aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2013-08-16 19:43:50 +0200
committerSven Gothel <[email protected]>2013-08-16 19:43:50 +0200
commitcd0e0465d753255ba0f98a21e3c72f22d8a4b598 (patch)
tree1590b7173315a2438f23f5ebf68765ba1bc42055 /src
parentbe0204ffe66bb9cb2918bfb01d0235fcaf0b3920 (diff)
SyncedRingbuffer Cleanup: private fields, clarify reset(boolean)
Diffstat (limited to 'src')
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java26
1 files changed, 12 insertions, 14 deletions
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<T> {
- 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<T> {
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 <code>null</code>.
@@ -91,16 +89,16 @@ public class SyncedRingbuffer<T> {
}
/**
- * 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;
}
}