Package org.apache.tomcat.jdbc.pool
Class MultiLockFairBlockingQueue<E>
java.lang.Object
org.apache.tomcat.jdbc.pool.MultiLockFairBlockingQueue<E>
- Type Parameters:
- E- Type of element in the queue
- All Implemented Interfaces:
- Iterable<E>,- Collection<E>,- BlockingQueue<E>,- Queue<E>
EXPERIMENTAL AND NOT YET COMPLETE!
 An implementation of a blocking queue with fairness waiting and lock dispersal to avoid contention.
 invocations to method poll(...) will get handed out in the order they were received.
 Locking is fine grained, a shared lock is only used during the first level of contention, waiting is done in a
 lock per thread basis so that order is guaranteed once the thread goes into a suspended monitor state.
 
Not all of the methods of the
Not all of the methods of the
BlockingQueue are implemented.- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classprotected classprotected class
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanbooleanaddAll(Collection<? extends E> c) voidclear()booleanbooleancontainsAll(Collection<?> c) intdrainTo(Collection<? super E> c) intdrainTo(Collection<? super E> c, int maxElements) element()intintbooleanisEmpty()iterator()booleanWill always return true, queue is unbounded.booleanWill never timeout, as it invokes theoffer(Object)method.peek()poll()Fair retrieval of an object in the queue.Request an item from the queue asynchronouslyvoidintremove()booleanbooleanremoveAll(Collection<?> c) booleanretainAll(Collection<?> c) intsize()take()Object[]toArray()<T> T[]toArray(T[] a) Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Collectionequals, hashCode, parallelStream, removeIf, spliterator, stream, toArray
- 
Constructor Details- 
MultiLockFairBlockingQueuepublic MultiLockFairBlockingQueue()Creates a new fair blocking queue.
 
- 
- 
Method Details- 
getNextPutpublic int getNextPut()
- 
getNextPollpublic int getNextPoll()
- 
offerWill always return true, queue is unbounded.
- 
offerWill never timeout, as it invokes theoffer(Object)method. Once a lock has been acquired, the- Specified by:
- offerin interface- BlockingQueue<E>
- Throws:
- InterruptedException
 
- 
pollFair retrieval of an object in the queue. Objects are returned in the order the threads requested them.- Specified by:
- pollin interface- BlockingQueue<E>
- Throws:
- InterruptedException
 
- 
pollAsyncRequest an item from the queue asynchronously- Returns:
- - a future pending the result from the queue poll request
 
- 
remove- Specified by:
- removein interface- BlockingQueue<E>
- Specified by:
- removein interface- Collection<E>
 
- 
sizepublic int size()- Specified by:
- sizein interface- Collection<E>
 
- 
iterator
- 
poll
- 
contains- Specified by:
- containsin interface- BlockingQueue<E>
- Specified by:
- containsin interface- Collection<E>
 
- 
add- Specified by:
- addin interface- BlockingQueue<E>
- Specified by:
- addin interface- Collection<E>
- Specified by:
- addin interface- Queue<E>
 
- 
drainTo- Specified by:
- drainToin interface- BlockingQueue<E>
- Throws:
- UnsupportedOperationException- - this operation is not supported
 
- 
drainTo- Specified by:
- drainToin interface- BlockingQueue<E>
- Throws:
- UnsupportedOperationException- - this operation is not supported
 
- 
put- Specified by:
- putin interface- BlockingQueue<E>
- Throws:
- InterruptedException
 
- 
remainingCapacitypublic int remainingCapacity()- Specified by:
- remainingCapacityin interface- BlockingQueue<E>
 
- 
take- Specified by:
- takein interface- BlockingQueue<E>
- Throws:
- InterruptedException
 
- 
addAll- Specified by:
- addAllin interface- Collection<E>
 
- 
clearpublic void clear()- Specified by:
- clearin interface- Collection<E>
- Throws:
- UnsupportedOperationException- - this operation is not supported
 
- 
containsAll- Specified by:
- containsAllin interface- Collection<E>
- Throws:
- UnsupportedOperationException- - this operation is not supported
 
- 
isEmptypublic boolean isEmpty()- Specified by:
- isEmptyin interface- Collection<E>
 
- 
removeAll- Specified by:
- removeAllin interface- Collection<E>
- Throws:
- UnsupportedOperationException- - this operation is not supported
 
- 
retainAll- Specified by:
- retainAllin interface- Collection<E>
- Throws:
- UnsupportedOperationException- - this operation is not supported
 
- 
toArray- Specified by:
- toArrayin interface- Collection<E>
- Throws:
- UnsupportedOperationException- - this operation is not supported
 
- 
toArraypublic <T> T[] toArray(T[] a) - Specified by:
- toArrayin interface- Collection<E>
- Throws:
- UnsupportedOperationException- - this operation is not supported
 
- 
element- Specified by:
- elementin interface- Queue<E>
- Throws:
- UnsupportedOperationException- - this operation is not supported
 
- 
peek- Specified by:
- peekin interface- Queue<E>
- Throws:
- UnsupportedOperationException- - this operation is not supported
 
- 
remove- Specified by:
- removein interface- Queue<E>
- Throws:
- UnsupportedOperationException- - this operation is not supported
 
 
-