411340 add comment why executeOnFillable defaults to true

This commit is contained in:
Thomas Becker 2013-06-21 15:28:33 +02:00
parent 918632d408
commit 4ba9385ebc
1 changed files with 10 additions and 5 deletions

View File

@ -53,11 +53,16 @@ public class SPDYConnection extends AbstractConnection implements Controller, Id
public SPDYConnection(EndPoint endPoint, ByteBufferPool bufferPool, Parser parser, Executor executor, public SPDYConnection(EndPoint endPoint, ByteBufferPool bufferPool, Parser parser, Executor executor,
boolean executeOnFillable, int bufferSize) boolean executeOnFillable, int bufferSize)
{ {
// Since SPDY is multiplexed, onFillable() must never block // Since SPDY is multiplexed, onFillable() must never block while calling application code. In fact,
// while calling application code. In fact, onFillable() // the SPDY code always dispatches to a new thread when calling application code,
// always dispatches to a new thread when calling application // so here we can safely pass false as last parameter, and avoid to dispatch to onFillable(). The IO
// code, so here we can safely pass false as last parameter, // operation (read, parse, etc.) will not block and will be fast in almost all cases. Big uploads to a server
// and avoid to dispatch to onFillable(). // however might block the Selector thread for a long time and therefore block other connections to be read.
// This might be a good reason to set executeOnFillable to true.
//
// Due to a jvm bug we've had a Selector thread being stuck at
// sun.nio.ch.FileDispatcherImpl.preClose0(Native Method). That's why we now default executeOnFillable to
// true even if for most use cases it is faster to not dispatch the IO events.
super(endPoint, executor, executeOnFillable); super(endPoint, executor, executeOnFillable);
this.bufferPool = bufferPool; this.bufferPool = bufferPool;
this.parser = parser; this.parser = parser;