Decrease ArrayDeque memory in SerializingExecutor

By default, ArrayDeque will be of size 16, which is an overkill for most
calls. "4" is not a magical number itself, but seems a better guess than
16 since we do have some knowledge of how much it will contain.

Resolves #320
This commit is contained in:
Eric Anderson 2015-05-19 09:36:15 -07:00
parent 2c7536c8fd
commit b69c59ce5f
1 changed files with 3 additions and 1 deletions

View File

@ -55,8 +55,10 @@ public final class SerializingExecutor implements Executor {
private final Executor executor;
/** A list of Runnables to be run in order. */
// Initial size set to 4 because it is a nice number and at least the size necessary for handling
// a unary response: onHeaders + onPayload + onClose
@GuardedBy("internalLock")
private final Queue<Runnable> waitQueue = new ArrayDeque<Runnable>();
private final Queue<Runnable> waitQueue = new ArrayDeque<Runnable>(4);
/**
* We explicitly keep track of if the TaskRunner is currently scheduled to