51 * An optionally-bounded {@linkplain BlockingDeque blocking deque} based on
52 * linked nodes.
53 *
54 * <p>The optional capacity bound constructor argument serves as a
55 * way to prevent excessive expansion. The capacity, if unspecified,
56 * is equal to {@link Integer#MAX_VALUE}. Linked nodes are
57 * dynamically created upon each insertion unless this would bring the
58 * deque above capacity.
59 *
60 * <p>Most operations run in constant time (ignoring time spent
61 * blocking). Exceptions include {@link #remove(Object) remove},
62 * {@link #removeFirstOccurrence removeFirstOccurrence}, {@link
63 * #removeLastOccurrence removeLastOccurrence}, {@link #contains
64 * contains}, {@link #iterator iterator.remove()}, and the bulk
65 * operations, all of which run in linear time.
66 *
67 * <p>This class and its iterator implement all of the <em>optional</em>
68 * methods of the {@link Collection} and {@link Iterator} interfaces.
69 *
70 * <p>This class is a member of the
71 * <a href="{@docRoot}/java/util/package-summary.html#CollectionsFramework">
72 * Java Collections Framework</a>.
73 *
74 * @since 1.6
75 * @author Doug Lea
76 * @param <E> the type of elements held in this deque
77 */
78 public class LinkedBlockingDeque<E>
79 extends AbstractQueue<E>
80 implements BlockingDeque<E>, java.io.Serializable {
81
82 /*
83 * Implemented as a simple doubly-linked list protected by a
84 * single lock and using conditions to manage blocking.
85 *
86 * To implement weakly consistent iterators, it appears we need to
87 * keep all Nodes GC-reachable from a predecessor dequeued Node.
88 * That would cause two problems:
89 * - allow a rogue Iterator to cause unbounded memory retention
90 * - cause cross-generational linking of old Nodes to new Nodes if
91 * a Node was tenured while live, which generational GCs have a
|
51 * An optionally-bounded {@linkplain BlockingDeque blocking deque} based on
52 * linked nodes.
53 *
54 * <p>The optional capacity bound constructor argument serves as a
55 * way to prevent excessive expansion. The capacity, if unspecified,
56 * is equal to {@link Integer#MAX_VALUE}. Linked nodes are
57 * dynamically created upon each insertion unless this would bring the
58 * deque above capacity.
59 *
60 * <p>Most operations run in constant time (ignoring time spent
61 * blocking). Exceptions include {@link #remove(Object) remove},
62 * {@link #removeFirstOccurrence removeFirstOccurrence}, {@link
63 * #removeLastOccurrence removeLastOccurrence}, {@link #contains
64 * contains}, {@link #iterator iterator.remove()}, and the bulk
65 * operations, all of which run in linear time.
66 *
67 * <p>This class and its iterator implement all of the <em>optional</em>
68 * methods of the {@link Collection} and {@link Iterator} interfaces.
69 *
70 * <p>This class is a member of the
71 * <a href="{@docRoot}/java.base/java/util/package-summary.html#CollectionsFramework">
72 * Java Collections Framework</a>.
73 *
74 * @since 1.6
75 * @author Doug Lea
76 * @param <E> the type of elements held in this deque
77 */
78 public class LinkedBlockingDeque<E>
79 extends AbstractQueue<E>
80 implements BlockingDeque<E>, java.io.Serializable {
81
82 /*
83 * Implemented as a simple doubly-linked list protected by a
84 * single lock and using conditions to manage blocking.
85 *
86 * To implement weakly consistent iterators, it appears we need to
87 * keep all Nodes GC-reachable from a predecessor dequeued Node.
88 * That would cause two problems:
89 * - allow a rogue Iterator to cause unbounded memory retention
90 * - cause cross-generational linking of old Nodes to new Nodes if
91 * a Node was tenured while live, which generational GCs have a
|