diff options
author | Sven Gothel <[email protected]> | 2013-08-15 14:33:41 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2013-08-15 14:33:41 +0200 |
commit | 16324775161ad34672a1506fd707107ac04b4437 (patch) | |
tree | ee3c60424375cf239622f21462ad9dad28f2d05a /src/jogl/classes/jogamp/opengl/util | |
parent | 6c72b1fc68e65bc0d4a0ee1e0442cc1637a67d01 (diff) |
SyncedRingbuffer: Add 'reset(boolean full)', simplify 'clear(..)'.
'reset(boolean full)' enables user to reset ringbuffer pointer and assume it's empty or full,
while 'clear()' shall only remove all references .. etc.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/util')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java b/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java index 9e1ec48f1..dff470eda 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/SyncedRingbuffer.java @@ -62,16 +62,14 @@ public class SyncedRingbuffer<T> { * <p> * The array may either be clear, or preset w/ elements! * </p> - * @param full if true, given array is assumed to be full, i.e. {@link #isFull()} will return true. + * @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. * @param array */ public SyncedRingbuffer(T[] array, boolean full) { this.array = array; this.capacity = array.length; - clearImpl(false); - if(full) { - size = capacity; - } + reset(full); } public final T[] getArray() { return array; } @@ -81,18 +79,28 @@ public class SyncedRingbuffer<T> { } /** - * Resets all ring buffer pointer to zero. + * Clears all ring buffer pointer to zero and set all ring buffer slots to <code>null</code>. * <p> * {@link #isEmpty()} will return <code>true</code> after calling this method. * </p> - * <p> - * If <code>clearRefs</code> is true, all ring buffer slots will be set to <code>null</code>. - * </p> - * @param clearRefs if true, all ring buffer slots will be flushed, otherwise they remain intact. */ - public final void clear(boolean clearRefs) { + public final void clear() { + synchronized ( sync ) { + clearImpl(true); + } + } + + /** + * Resets all ring buffer pointer to zero 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(clearRefs); + clearImpl(false); + } + if(full) { + size = capacity; } } |