org.mapdb
Class Queues.SimpleQueue<E>

java.lang.Object
  extended by org.mapdb.Queues.SimpleQueue<E>
All Implemented Interfaces:
Iterable<E>, Collection<E>, BlockingQueue<E>, Queue<E>
Direct Known Subclasses:
Queues.CircularQueue, Queues.Queue, Queues.Stack
Enclosing class:
Queues

public abstract static class Queues.SimpleQueue<E>
extends Object
implements BlockingQueue<E>


Nested Class Summary
protected static class Queues.SimpleQueue.Node<E>
           
protected static class Queues.SimpleQueue.NodeSerializer<E>
           
 
Field Summary
protected  Engine engine
           
protected  Atomic.Long head
           
protected  ReentrantLock[] locks
           
protected  Serializer<Queues.SimpleQueue.Node<E>> nodeSerializer
           
protected  Serializer<E> serializer
           
protected static int TICK
           
protected  boolean useLocks
           
 
Constructor Summary
Queues.SimpleQueue(Engine engine, Serializer<E> serializer, long headRecidRef, boolean useLocks)
           
 
Method Summary
 boolean addAll(Collection<? extends E> c)
           
 void clear()
           
 void close()
          Closes underlying storage and releases all resources.
 boolean contains(Object o)
           
 boolean containsAll(Collection<?> c)
           
 int drainTo(Collection<? super E> c)
           
 int drainTo(Collection<? super E> c, int maxElements)
           
 E element()
           
 boolean isEmpty()
           
 Iterator<E> iterator()
           
 boolean offer(E e)
           
 boolean offer(E e, long timeout, TimeUnit unit)
           
 E peek()
           
 E poll()
           
 E poll(long timeout, TimeUnit unit)
           
 void put(E e)
           
 int remainingCapacity()
           
 E remove()
           
 boolean remove(Object o)
           
 boolean removeAll(Collection<?> c)
           
 boolean retainAll(Collection<?> c)
           
 int size()
           
 E take()
           
 Object[] toArray()
           
<T> T[]
toArray(T[] a)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.concurrent.BlockingQueue
add
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Field Detail

useLocks

protected final boolean useLocks

locks

protected final ReentrantLock[] locks

TICK

protected static final int TICK
See Also:
Constant Field Values

engine

protected final Engine engine

serializer

protected final Serializer<E> serializer

head

protected final Atomic.Long head

nodeSerializer

protected final Serializer<Queues.SimpleQueue.Node<E>> nodeSerializer
Constructor Detail

Queues.SimpleQueue

public Queues.SimpleQueue(Engine engine,
                          Serializer<E> serializer,
                          long headRecidRef,
                          boolean useLocks)
Method Detail

close

public void close()
Closes underlying storage and releases all resources. Used mostly with temporary collections where engine is not accessible.


peek

public E peek()
Specified by:
peek in interface Queue<E>

poll

public E poll()
Specified by:
poll in interface Queue<E>

clear

public void clear()
Specified by:
clear in interface Collection<E>

remove

public E remove()
Specified by:
remove in interface Queue<E>

element

public E element()
Specified by:
element in interface Queue<E>

offer

public boolean offer(E e)
Specified by:
offer in interface BlockingQueue<E>
Specified by:
offer in interface Queue<E>

put

public void put(E e)
         throws InterruptedException
Specified by:
put in interface BlockingQueue<E>
Throws:
InterruptedException

offer

public boolean offer(E e,
                     long timeout,
                     TimeUnit unit)
              throws InterruptedException
Specified by:
offer in interface BlockingQueue<E>
Throws:
InterruptedException

take

public E take()
       throws InterruptedException
Specified by:
take in interface BlockingQueue<E>
Throws:
InterruptedException

poll

public E poll(long timeout,
              TimeUnit unit)
       throws InterruptedException
Specified by:
poll in interface BlockingQueue<E>
Throws:
InterruptedException

drainTo

public int drainTo(Collection<? super E> c)
Specified by:
drainTo in interface BlockingQueue<E>

drainTo

public int drainTo(Collection<? super E> c,
                   int maxElements)
Specified by:
drainTo in interface BlockingQueue<E>

remainingCapacity

public int remainingCapacity()
Specified by:
remainingCapacity in interface BlockingQueue<E>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface Collection<E>

size

public int size()
Specified by:
size in interface Collection<E>

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<E>
Specified by:
contains in interface BlockingQueue<E>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E>
Specified by:
iterator in interface Collection<E>

toArray

public Object[] toArray()
Specified by:
toArray in interface Collection<E>

toArray

public <T> T[] toArray(T[] a)
Specified by:
toArray in interface Collection<E>

remove

public boolean remove(Object o)
Specified by:
remove in interface Collection<E>
Specified by:
remove in interface BlockingQueue<E>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<E>

addAll

public boolean addAll(Collection<? extends E> c)
Specified by:
addAll in interface Collection<E>

removeAll

public boolean removeAll(Collection<?> c)
Specified by:
removeAll in interface Collection<E>

retainAll

public boolean retainAll(Collection<?> c)
Specified by:
retainAll in interface Collection<E>


Copyright © 2014. All Rights Reserved.