< prev index next >

src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java

Print this page




 142      */
 143     transient Node<E> first;
 144 
 145     /**
 146      * Pointer to last node.
 147      * Invariant: (first == null && last == null) ||
 148      *            (last.next == null && last.item != null)
 149      */
 150     transient Node<E> last;
 151 
 152     /** Number of items in the deque */
 153     private transient int count;
 154 
 155     /** Maximum number of items in the deque */
 156     private final int capacity;
 157 
 158     /** Main lock guarding all access */
 159     final ReentrantLock lock = new ReentrantLock();
 160 
 161     /** Condition for waiting takes */

 162     private final Condition notEmpty = lock.newCondition();
 163 
 164     /** Condition for waiting puts */

 165     private final Condition notFull = lock.newCondition();
 166 
 167     /**
 168      * Creates a {@code LinkedBlockingDeque} with a capacity of
 169      * {@link Integer#MAX_VALUE}.
 170      */
 171     public LinkedBlockingDeque() {
 172         this(Integer.MAX_VALUE);
 173     }
 174 
 175     /**
 176      * Creates a {@code LinkedBlockingDeque} with the given (fixed) capacity.
 177      *
 178      * @param capacity the capacity of this deque
 179      * @throws IllegalArgumentException if {@code capacity} is less than 1
 180      */
 181     public LinkedBlockingDeque(int capacity) {
 182         if (capacity <= 0) throw new IllegalArgumentException();
 183         this.capacity = capacity;
 184     }




 142      */
 143     transient Node<E> first;
 144 
 145     /**
 146      * Pointer to last node.
 147      * Invariant: (first == null && last == null) ||
 148      *            (last.next == null && last.item != null)
 149      */
 150     transient Node<E> last;
 151 
 152     /** Number of items in the deque */
 153     private transient int count;
 154 
 155     /** Maximum number of items in the deque */
 156     private final int capacity;
 157 
 158     /** Main lock guarding all access */
 159     final ReentrantLock lock = new ReentrantLock();
 160 
 161     /** Condition for waiting takes */
 162     @SuppressWarnings("serial") // Not statically typed as Serializable
 163     private final Condition notEmpty = lock.newCondition();
 164 
 165     /** Condition for waiting puts */
 166     @SuppressWarnings("serial") // Not statically typed as Serializable
 167     private final Condition notFull = lock.newCondition();
 168 
 169     /**
 170      * Creates a {@code LinkedBlockingDeque} with a capacity of
 171      * {@link Integer#MAX_VALUE}.
 172      */
 173     public LinkedBlockingDeque() {
 174         this(Integer.MAX_VALUE);
 175     }
 176 
 177     /**
 178      * Creates a {@code LinkedBlockingDeque} with the given (fixed) capacity.
 179      *
 180      * @param capacity the capacity of this deque
 181      * @throws IllegalArgumentException if {@code capacity} is less than 1
 182      */
 183     public LinkedBlockingDeque(int capacity) {
 184         if (capacity <= 0) throw new IllegalArgumentException();
 185         this.capacity = capacity;
 186     }


< prev index next >