@@ -0,0 +1,1007 @@
+package org.shoushitsu.util.asyncservice;%0A%0Aimport java.util.Collection;%0A%0A/**%0A * A simple bounded task queue with a single %7B@linkplain #sink sink%7D.%0A */%0Apublic final class BoundedTaskQueue extends ATaskQueue %7B%0A%0A%09private final BoundedArrayQueue tasks;%0A%0A%09/**%0A%09 * The sink that feeds into this queue.%0A%09 */%0A%09public final TaskSink sink;%0A%0A%09/**%0A%09 * Create a bounded task queue.%0A%09 *%0A%09 * @param externalCapacityLog2 binary logarithm of the desired maximum queue size.%0A%09 *%0A%09 * @throws java.lang.IllegalArgumentException if %7B@code externalCapacityLog2 %3C 0 %7C%7C externalCapacityLog2 %3E 30%7D.%0A%09 */%0A%09public BoundedTaskQueue(int externalCapacityLog2) %7B%0A%09%09tasks = new BoundedArrayQueue(externalCapacityLog2);%0A%09%09sink = createSink(new BoundedArrayQueueSinkImpl(tasks));%0A%09%7D%0A%0A%09@Override%0A%09protected final boolean isEmpty() %7B%0A%09%09return tasks.isEmpty();%0A%09%7D%0A%0A%09@Override%0A%09protected final Task%3C?%3E poll() %7B%0A%09%09return tasks.poll();%0A%09%7D%0A%0A%09@Override%0A%09protected final void doDrainTo(Collection%3CTask%3C?%3E%3E sink) %7B%0A%09%09sink.addAll(tasks.drain());%0A%09%7D%0A%0A%7D%0A

add BoundedTaskQueue