public class HostLimitQueue extends LinkedBlockingDeque<Runnable>
Modifier and Type | Field and Description |
---|---|
private int |
hostLimit |
private Map<String,Semaphore> |
hostSemaphores |
private static long |
serialVersionUID |
Constructor and Description |
---|
HostLimitQueue(int hostLimit)
Creates an unbounded queue
|
Modifier and Type | Method and Description |
---|---|
private void |
acquireSemaphore(Runnable job) |
private JCSCachedTileLoaderJob<?,?> |
findJob() |
private Semaphore |
getSemaphore(JCSCachedTileLoaderJob<?,?> job) |
Runnable |
poll(long timeout,
TimeUnit unit) |
private void |
releaseSemaphore(JCSCachedTileLoaderJob<?,?> job) |
Runnable |
take() |
private boolean |
tryAcquireSemaphore(JCSCachedTileLoaderJob<?,?> job) |
add, addFirst, addLast, clear, contains, descendingIterator, drainTo, drainTo, element, getFirst, getLast, iterator, offer, offer, offerFirst, offerFirst, offerLast, offerLast, peek, peekFirst, peekLast, poll, pollFirst, pollFirst, pollLast, pollLast, pop, push, put, putFirst, putLast, remainingCapacity, remove, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, size, spliterator, takeFirst, takeLast, toArray, toArray, toString
addAll
containsAll, isEmpty, removeAll, retainAll
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addAll, containsAll, equals, hashCode, isEmpty, parallelStream, removeAll, removeIf, retainAll, stream
private static final long serialVersionUID
private final Map<String,Semaphore> hostSemaphores
private final int hostLimit
public HostLimitQueue(int hostLimit)
hostLimit
- how many parallel calls to host to allowprivate JCSCachedTileLoaderJob<?,?> findJob()
public Runnable poll(long timeout, TimeUnit unit) throws InterruptedException
poll
in interface BlockingDeque<Runnable>
poll
in interface BlockingQueue<Runnable>
poll
in class LinkedBlockingDeque<Runnable>
InterruptedException
public Runnable take() throws InterruptedException
take
in interface BlockingDeque<Runnable>
take
in interface BlockingQueue<Runnable>
take
in class LinkedBlockingDeque<Runnable>
InterruptedException
private Semaphore getSemaphore(JCSCachedTileLoaderJob<?,?> job)
private void acquireSemaphore(Runnable job) throws InterruptedException
InterruptedException
private boolean tryAcquireSemaphore(JCSCachedTileLoaderJob<?,?> job)
private void releaseSemaphore(JCSCachedTileLoaderJob<?,?> job)