421697 - IteratingCallback improvements

made gather size configurable
This commit is contained in:
Greg Wilkins 2013-11-21 16:00:50 +11:00
parent 29fdeba061
commit 23091e2272
2 changed files with 6 additions and 7 deletions

View File

@ -36,7 +36,7 @@ import org.eclipse.jetty.util.log.Logger;
public class Flusher public class Flusher
{ {
private static final Logger LOG = Log.getLogger(Flusher.class); private static final Logger LOG = Log.getLogger(Flusher.class);
private static final int MAX_GATHER = 10; private static final int MAX_GATHER = Integer.getInteger("org.eclipse.jetty.spdy.Flusher.MAX_GATHER",8);
private final FlusherCB flusherCB = new FlusherCB(); private final FlusherCB flusherCB = new FlusherCB();
private final Controller controller; private final Controller controller;

View File

@ -44,7 +44,7 @@ import org.eclipse.jetty.websocket.common.frames.DataFrame;
*/ */
public class FrameFlusher public class FrameFlusher
{ {
private static final int MAX_GATHER = Integer.getInteger("org.eclipse.jetty.websocket.common.io.FrameFlusher.MAX_GATHER",8);
private static final Logger LOG = Log.getLogger(FrameFlusher.class); private static final Logger LOG = Log.getLogger(FrameFlusher.class);
/** The endpoint to flush to */ /** The endpoint to flush to */
@ -61,8 +61,7 @@ public class FrameFlusher
/** the buffer input size */ /** the buffer input size */
private int bufferSize = 2048; private int bufferSize = 2048;
/** the gathered write bytebuffer array limit */
private int gatheredBufferLimit = 10;
/** Tracking for failure */ /** Tracking for failure */
private Throwable failure; private Throwable failure;
/** Is WriteBytesProvider closed to more WriteBytes being enqueued? */ /** Is WriteBytesProvider closed to more WriteBytes being enqueued? */
@ -209,8 +208,8 @@ public class FrameFlusher
private class FlusherCB extends IteratingCallback private class FlusherCB extends IteratingCallback
{ {
private final ArrayQueue<FrameEntry> active = new ArrayQueue<>(lock); private final ArrayQueue<FrameEntry> active = new ArrayQueue<>(lock);
private final List<ByteBuffer> buffers = new ArrayList<>(gatheredBufferLimit*2); private final List<ByteBuffer> buffers = new ArrayList<>(MAX_GATHER*2);
private final List<FrameEntry> succeeded = new ArrayList<>(gatheredBufferLimit+1); private final List<FrameEntry> succeeded = new ArrayList<>(MAX_GATHER+1);
@Override @Override
protected void completed() protected void completed()
@ -228,7 +227,7 @@ public class FrameFlusher
// If we exited the loop above without hitting the gatheredBufferLimit // If we exited the loop above without hitting the gatheredBufferLimit
// then all the active frames are done, so we can add some more. // then all the active frames are done, so we can add some more.
while (buffers.size()<gatheredBufferLimit && !queue.isEmpty()) while (buffers.size()<MAX_GATHER && !queue.isEmpty())
{ {
FrameEntry frame = queue.remove(0); FrameEntry frame = queue.remove(0);
active.add(frame); active.add(frame);